Free Support Forum -

Inserting a table inside another table

Hello Support,

I am trying to insert a table into another table. The parent table contains a bookmark called "TableHolder", which is present in a cell. I would like to insert my new table at the place of the bookmark. The new table is of format "Aspose.Words.Tables.Table", and copied from another word document. I am able to insert the new table to that page using the following command:


but not at that bookmark. When I am trying to insert at the bookmark, I am getting a exception called "cannot insert this node type at this location". I have checked the node type is "table". I am attaching the input template for reference. Can you please help me.




Thanks for your request. You can use code like the following to insert a table at bookmark:

// Get a node where the bookmark is located.

Node bookmarkParent = doc.Range.Bookmarks["myBookmark"].BookmarkStart.ParentNode;

// Insert a table.

bookmarkParent.ParentNode.InsertAfter(table, bookmarkParent);

Hope this helps.

Best regards,

Thanks this worked for me :slight_smile: