How to remove a table row containing a bookmark?

How can I remove one table row which contains a specific bookmark ?

I have searched the forum but the closest solution I've found is using a ForEach loop to scan every row in every table in the document in order to find a specific text. In my case, I would prefer searching for only one specific bookmark and delete the entire row if it is found.

Hi,

If you know the name of the bookmark and it is located in a table cell, removing the parent row is pretty easy:

doc.Range.Bookmarks["MyBookmark"].BookmarkStart.ParentNode.ParentNode.ParentNode.Remove();

I could be more helpful if you attached your document. Please do that unless the solution works.

Thanks a million. It works beautifully.

Josie

too many parent nodes to traverse ...

a possibly simpler approach:

Row row = (Row)doc.Range.Bookmarks["MyBookmark"].BookmarkStart.GetAncestor(typeof(Row));

row.Remove();

Thank you both, Roman and Dmitry.

Here is the translation in VB for those who might be interested:

Dim Row As Row = Doc.Range.Bookmarks("MyBookmark").BookmarkStart.GetAncestor(GetType(Row))

Row.Remove()