i write this post because i dont know how to increase my convert function for text pattern "[%name_0%]" convert to word bookmark.
- Code: Select all
Using docBase As New Document("C:\tmp\Base.docx")
Dim f As Regex = New Regex("\[\%[\w]+\%\]")
Dim selections As TextSelection() = docBase.FindAllPattern(f)
For Each selection As TextSelection In selections
Dim range As TextRange = selection.GetAsOneRange()
Dim id As Integer = range.OwnerParagraph.ChildObjects.IndexOf(range)
Dim par As Paragraph = range.OwnerParagraph
Dim nomSignet As String = range.Text.Replace("[%}", "")
nomSignet = nomSignet.Replace("{%]", "")
par.AppendBookmarkStart(nomSignet)
par.AppendBookmarkEnd(nomSignet)
range.Text = ""
Dim bookmarkNavigator As BookmarksNavigator = New BookmarksNavigator(docBase)
bookmarkNavigator.MoveToBookmark(nomSignet)
bookmarkNavigator.InsertText(nomSignet)
Next
docBase.SaveToFile("C:\tmp\Baseresult.docx", FileFormat.Auto)
End Using
can you give me some idea to set directly the text betweenAppendBookmarkStart and AppendBookmarkEnd ?
i try to set bookmarstart to par(id -1) (the end select pargraph -1) but that wont work
thank's
FH