Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using Microsoft.Office.Interop
  2. using System.IO
  3. Microsoft.Office.Interop.Word
  4.  
  5. Object objMiss = System.Reflection.Missing.Value;
  6. Microsoft.Office.Interop.Word.Application ObjWord = new Microsoft.Office.Interop.Word.Application();
  7. string url = "D:\Desktop\plantilla.docx";//Server.MapPath("D://Documentos/Prueba.docx");//Path.GetFullPath("~/Prueba.docx");
  8.  
  9. object url2 = "D:\Desktop\plantilla.docx";
  10. Label1.Text = url;
  11. Response.Write(url);
  12. object nombre = "PRUEBA";
  13. Microsoft.Office.Interop.Word.Document objDoc = ObjWord.Documents.Open(ref url2, objMiss);
  14. Microsoft.Office.Interop.Word.Range nom = objDoc.Bookmarks.get_Item(ref nombre).Range;
  15.  
  16. nom.Text = "prueba2";
  17.  
  18. object obj = nom;
  19. objDoc.Bookmarks.Add("nombre", ref obj);
  20. objDoc.Bookmarks.Add("telefono").Range.Text = txt_Nit.Text; // el txt_nit lo toma de la caja de texto
  21.  
  22. ObjWord.Visible = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement