Right now I have a Word Document with the following text:
FullName Position Address
Each line is made as a separate bookmark. The bookmark name for each line is the same as the word (the bookmark for FullName is FullName).
When I iterate through the bookmarks and update the text of the three different bookmarks, the first two get deleted and I am just left with the address. I think some how the bookmarks are getting combined in the editing process somehow.
Here is the code I have:
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "Word|*.docx"
saveFileDialog1.Title = "Save your report file"
Dim FilePath = "C:\Users\Administrator.Laptop1\Desktop\TESTER.docx"
Dim myWordDoc As Microsoft.Office.Interop.Word.Document
Dim myWordApp As Microsoft.Office.Interop.Word.Application
Dim filepathname As Object = TryCast(FilePath, Object)
Dim missing As Object = Type.Missing
Dim objTrue As Object = TryCast(True, Object)
' create Word.Application object for the document
myWordApp = New Microsoft.Office.Interop.Word.Application
' open the document
myWordDoc = myWordApp.Documents.Open(filepathname, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
'update Opinion
myWordDoc.Bookmarks("SendDate").Range.Text = (Convert.ToDateTime(TextBox7.Text)).ToString("MMMM dd, yyyy")
myWordDoc.Bookmarks("FullName").Range.Text = TextBox4.Text & " " & TextBox5.Text & " " & TextBox6.Text & vbLf
myWordDoc.Bookmarks("Position").Range.Text = TextBox8.Text & vbLf