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

bookmark in a cell

Thread ID:

Created:

Updated:

Platform:

Replies:

141923 Jan 10,2019 02:41 PM UTC Jan 16,2019 09:07 AM UTC WinForms 1
loading
Tags: DocIO
AtliDev
Asked On January 10, 2019 02:41 PM UTC

Hi,
i'am always evaluate your product,
i have a table with two rows
the first one is the header and the second in empty

the first row containt cells with specific bookmark,
i want to recupere the cellindex of specific bookmark

i use the current code but he don't find any bookmark in cell just wtextrange.

//code
      Dim bknav As BookmarksNavigator = New BookmarksNavigator(a)
      bknav.MoveToBookmark("tableauAC1")
 Dim tbp As TextBodyPart = bknav.GetBookmarkContent
        Dim table As WTable = Nothing
        For Each element As IEntity In tbp.BodyItems
            If TypeOf element Is WTable Then
                table = CType(element, WTable)
                Exit For
            End If
        Next

For Each cell As WTableCell In table.Rows(0).Cells
            For Each para As WParagraph In cell.Paragraphs   ' y a que paragraph a l'interieur
                For Each element In para.ChildEntities
                    If TypeOf (element) Is BookmarkStart Then
                        bkname = TryCast(element, BookmarkStart).Name
                        currindex = cell.GetCellIndex
                        If bkname = "numLocalAC1" Then
                            indexNom = currindex
                            bktodelete.Add(bkname)
                        End If
                        If bkname = "localAC1" Then
                            indexPrenom = currindex
                            bktodelete.Add(bkname)
                        End If
                        If bkname = "numLotAC1" Then
                            indextelephone = currindex
                            bktodelete.Add(bkname)
                        End If
                    End If
                Next
            Next
        Next
// end code

in piece joint you  will find the document.

-------- ADD ------
after i use the 16.4 librairy the espion express don't give me any information.


thanks have a nice day


Attachment: exemple_93b491c5.zip

Vijay Ramachandran [Syncfusion]
Replied On January 16, 2019 09:07 AM UTC

Hi AtliDev,

Thank you for contacting Syncfusion support.

You can get the bookmark owner cell index by using BookmarkNagivator. Please find the example code snippet from below and let us know if it helps.
 
Dim document As WordDocument = New WordDocument("exemple.docx") 
    Dim bkmkNavigator As BookmarksNavigator = New BookmarksNavigator(document) 
    bkmkNavigator.MoveToBookmark("numLocalAC1") 
    Dim cellIndex As Integer = -1 
 
    If bkmkNavigator.CurrentBookmark IsNot Nothing AndAlso bkmkNavigator.CurrentBookmark.BookmarkStart IsNot Nothing Then 
        Dim ownerParagraph As WParagraph = bkmkNavigator.CurrentBookmark.BookmarkStart.OwnerParagraph 
 
        If ownerParagraph.IsInCell Then 
            Dim ownerCell As WTableCell = TryCast(ownerParagraph.OwnerTextBody, WTableCell) 
            If ownerCell IsNot Nothing Then cellIndex = ownerCell.GetCellIndex() 
        End If 
    End If 

You can find the runnable example project from below:
http://www.syncfusion.com/downloads/support/forum/141923/ze/Bookmark1881819878

Regards,
Vijay R
 


CONFIRMATION

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

;