Inserting bookmark across paragraph
Dim paraStart As WParagraph = selBegin.GetAsOneRange().OwnerParagraph ' paragraph of the first {SE}
Dim selEnd As TextSelection ' selection of the first {FINE_SE}
Dim paraEnd As WParagraph = selEnd.GetAsOneRange().OwnerParagraph ' paragraph of the first {FINE_SE}
Dim bookmarkName As String = "BKM_DEL"
Dim bStart As BookmarkStart = New BookmarkStart(_wordDocument, bookmarkName)
paraStart.Items.Insert(paraStartIndex, bStart)
paraEnd.AppendBookmarkEnd(bookmarkName)
Attachment: chiara_model_e0c527b8.zip
Hi Chiara,
Thank you for contacting Syncfusion product,
Instead of using your code snippet for removing the content from the text selection please use the below code snippet for removing the text section from the document.
Code Snippet:
'Gets start selection text
Dim startselection As TextSelection = wordDoc.Find("{SE}", True, True)
'Gets end selection text
Dim endselection As TextSelection = wordDoc.Find("{FINE_SE}", True, True)
'Gets the textrange from the start selection
Dim startparaitem As WTextRange = startselection.GetAsOneRange()
'Gets the textrange from the end selection
Dim endparaitem As WTextRange = endselection.GetAsOneRange()
'Gets the owner paragraph from the start selection
Dim startpara As WParagraph = startselection.GetAsOneRange().OwnerParagraph
'Gets the owner paragraph from the end selection
Dim endpara As WParagraph = endselection.GetAsOneRange().OwnerParagraph
Dim name As String = "BKM_DEL"
'Create bookmark start
Dim bookstart As New Syncfusion.DocIO.DLS.BookmarkStart(wordDoc, Name)
'Create bookmark end
Dim bookend As New Syncfusion.DocIO.DLS.BookmarkEnd(wordDoc, Name)
'Insert the startbookmark
startpara.Items.Insert(startpara.Items.IndexOf(startparaitem), bookstart)
'Insert the endbookmark
endpara.Items.Insert(endpara.Items.IndexOf(endparaitem) + 1, bookend)
Dim nav As New BookmarksNavigator(wordDoc)
'Navigate the bookmark
nav.MoveToBookmark(name)
'Remove the bookmark content
nav.DeleteBookmarkContent(False)
Regards,
Narendran
- 1 Reply
- 2 Participants
-
CM Chiara Marzano
- Sep 23, 2015 04:17 PM UTC
- Sep 24, 2015 02:24 PM UTC