Free Support Forum - aspose.com

Bolding the text inserted at a bookmark

Hi,

I have the following code:

Dim doc As Document = New Document(word_templates_path & strTemplate)

Dim docBuilder As New DocumentBuilder(doc)

Dim bookmarks As Bookmarks = doc.Range.Bookmarks

Dim strBookmarkStyle As String = "Bold"

Dim strBookmarkName As String = "Bookmark1"

If Not bookmarks(strBookmarkName) Is Nothing Then

If strBookmarkStyle = "Bold" Then

docBuilder.MoveToBookmark(strBookmarkName)

docBuilder.Font.Bold = True

Else

docBuilder.Font.Bold = False

End If

bookmarks(strBookmarkName).Text = "some text"

End If

Assume that the document has a bookmark named "Bookmark1". I am trying to insert the string "some text" at Bookmark1 and have it appear bold. The text is inserted successfully, but is not bolded. Is there anything I am missing or doing wrong?

Thanks for your help.

C.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Please try using the following code:

docBuilder.MoveToBookmark(strBookmarkName, True, True)

docBuilder.Font.Bold = True

docBuilder.Write("some text")

Hope this helps.

Best regards.

Hi Alexey,

Thanks so much for your help. I made the changes to my code as you suggested and it works perfectly!

Thanks again!