We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Inserting bookmark across paragraph

Thread ID:





120527 Sep 23,2015 04:17 PM UTC Sep 24,2015 02:24 PM UTC WinForms 1
Tags: DocIO
Chiara Marzano
Asked On September 23, 2015 04:17 PM UTC

Good evening
We're using DocIo v.13.1 in order to manage Word Document.
We have a .doc "model", that contains specific text that we use as a TAG, to identify particular text.
We'd need to leave or remove a portion of text between two tags: to do it, we'd like to use bookmarks... but we're finding some problems.
The "model" contains the following text
{SE} testo sulla prima riga
testo sulla seconda riga
testo sulla terza riga {FINE_SE}{SE}
seconda condizione
terza condizione {FINE_SE}
We'd like to remove the bold text, that is splitted on 3 paragraph, and obtain the following result:
seconda condizione
terza condizione {FINE_SE}
Now we're using the following code, but it doesn't run fine, because it removes the second "{SE}" tag at the end of the 3^ line:
dim selBegin As TextSelection       ' selection of the first {SE}
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)
We know that the last paraEnd.AppendBookmarkEnd () function is the cause :-)
But we didn't find other way to do it.
Do you have any suggestion?
Thank you in advance
Best regards
Chiara Marzano
Sistemi S.p.A.
PS: I've attached the "model": we'd like to remove all the Yellow text, but keep the blue one :-)
Thank you!!
seconda condizione
terza condizione {FINE_SE}
We have









Attachment: chiara_model_e0c527b8.zip

Narendran Srinivasan [Syncfusion]
Replied On September 24, 2015 02:24 PM UTC

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


    'Remove the bookmark content




This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon