We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Bolding the text inserted at a bookmark

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.Font.Bold = True
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.

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!