0

I can't figure out how I can change the font style/color of a specific bookmark. Every time I try something, I keep getting the null exception error and and I can't figure out where I'm going wrong in referencing the bookmark itself.

Here's what I've got so far in creating the bookmark:

oWord = CreateObject("Word.Application")
        oWord.Visible = True
        oDoc = oWord.Documents.Add("path and location of Template.dotx")

        oDoc.Bookmarks.Item("Bookmark1").Range.Text = Textbox1.Text
        'I keep thinking something like this next line will work, but to no avail
        oDoc.Bookmarks.Item("Bookmark1").Range.Font.color = Word.WdColor.wdColorAqua
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Begginnerdev
0

Here is a good starting point.

This was pulled directly from that page:

Private Sub BookmarkFont()

Me.Paragraphs(1).Range.InsertParagraphBefore()
Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
    Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
Bookmark1.Text = "This is sample bookmark text."
Bookmark1.Words(3).Font.Color = Word.WdColor.wdColorBlue

End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.