We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot insert node of this type at this location error

Hi,

I m trying an existing table copy in a document with InsertNode but i get an exception 'Cannot insert node of this type at this location error' at runtime. Could you please look at the code below and tell me what I'm doing wrong?

Thanks..

private void SetSameBookmarkContents(string bookmarkName, Node node)

{

if (node == null) return;

string strBookmarkName = this.GetBookmarkName(bookmarkName);

while (strBookmarkName != bookmarkName)

{

if (this.MoveToBookmark(strBookmarkName)) this.InsertNode(node.Clone(true)); // I get exception at this line, also i tryed this.InsertNode(node) but result did no changed; .

strBookmarkName = this.GetBookmarkName(bookmarkName);

}

}

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Using InsertNode method you can insert text level nodes only (Run, Shape). I think you should use InsertBefore or InsertAfter method. For example see the following code:

builder.CurrentParagraph.ParentNode.InsertAfter(myTable, builder.CurrentParagraph);

Also see the following link.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.compositenode.insertafter.html

Hope this helps.

Best regards.

Thank you for interest and reply. It's ok.

Good working...