Ticket T937392
Visible to All Users

How to iterate through document bookmarks and find bookmarks located in tables cells

created 4 years ago (modified 4 years ago)

Hello,

in our project we use some "legacy" .dotx word templates to fill with data.
These templates are still in use by an old access application.
It's intended to use these old templates more ore less unmodified by the new wpf application.

Here is the problem:
The templates contain tables.
In the rows of these tables are bookmarks.

The old process is filling in data at the position of the bookmarks.
If there is no data, the whole table row, where the bookmark is, gets deleted from the table.

Currently I can not find a connection between a bookmark and a table(row) and therefore can not figure out, which row to delete.

An example is attached.

Thank you.

Answers approved by DevExpress Support

created 4 years ago

Hi Norman,
To accomplish this task, you need to iterate through the RichEditControl.Document.Bookmarks collection. For each bookmark, obtain the table cell where this bookmark is located using the Document.Tables.GetTableCellDocument.Tables.GetTableCell method (pass the bookmark start position to the GetTableCell method as a parameter). The GetTableCell method returns the TableCell object that stores the parent table row in the Row property. To delete this row, invoke the TableRow.Delete method.
I hope that you will find this information helpful.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.