Writing formatted text at a bookmark in Word
I been going over a few of the posts on opening Word documents and writing to them at a Bookmark through VB.NET and I have that working OK. What I would like to do is use bold and underlining formatting (and more no doubt)
At the top of the class I have
Code:
Private WordApp As New Word.Application
and the main code is:
Code:
Dim fileName As Object = "C:\Proposal.doc"
Dim [readOnly] As Object = False
Dim isVisible As Object = True
Dim missing As Object = System.Reflection.Missing.Value
Dim WordDoc As New Word.Document
WordApp.Visible = True
WordDoc = WordApp.Documents.Open(fileName, missing,
[readOnly], missing, missing, missing, missing, missing, missing,
missing, missing, isVisible)
WordApp.Activate()
WordDoc.Bookmarks.Item("MyBookmark").Range.Text = "I am a line of text"
If I were to start typing at the start of the document the following works:
Code:
WordApp.Selection.Font.Bold = True
WordApp.Selection.TypeText("Bold Text")
WordApp.Selection.Font.Bold = False
but I can't this working at the bookmark.
Help much appreciated