Dim a As WordDocument = New WordDocument("Sample.docx", FormatType.Doc)
Dim bknav As BookmarksNavigator = New BookmarksNavigator(a)
bknav.MoveToBookmark("casa")
Dim d As WordDocument = New WordDocument
Dim tbp As TextBodyPart = New TextBodyPart(d)
Dim para As WParagraph = d.CreateParagraph
'Append text into the paragraph.
Dim textRange As IWTextRange = para.AppendText("paragraph of element")
'Set character format for text.
textRange.CharacterFormat.Bold = True
'Apply paragraph format for the paragraph.
para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center
tbp.BodyItems.Add(para)
bknav.ReplaceBookmarkContent(tbp)
d.Close()
tbp.Close()
a.Save("Result.docx") |