I have 2 Word docs, doc 1 and doc 2, and I would like to copy the table in doc 1 to doc 2. Doc 1 has two tables and I would like to copy the second table. How would I be able to do this.
Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. You should use ImportNode method to copy nodes from one document to another. Please see the following link for more information.
Also the following code shows how you can copy table from one document to another.
//Open sorse and destination documents
Document srcDoc = new Document(@"Test139\src.doc");
Document dstDoc = new Document(@"Test139\dst.doc");
//Get collection of Tables from the source document
NodeCollection tables = srcDoc.GetChildNodes(NodeType.Table, true);
//Get the secont table
Node secondTable = tables;
//Import this table into the destination document
Node dstNode = dstDoc.ImportNode(secondTable, true, ImportFormatMode.KeepSourceFormatting);
//Insert table into the destination document
//Save output document
Hope this helps.