Free Support Forum - aspose.com

Possibility of InsertFile function

Are there any future plans of implementing a function similiar to the InsertFile function of Word? We need the ability to insert an existing Aspose.Word document into another Aspose.Word document.

You can do it using ImportNode method of the Document class,

Check the following projects in Demos:

Aspose.Word.Demos.WinForms for C#

Aspose.Word.Demos.WinForms.VisualBasic for VB

The code looks like this:

///

/// Copies all sections from one document to another.

///

private void AppendDoc(Document dstDoc, Document srcDoc) {

for (int i = 0; i < srcDoc.Sections.Count; i++) {

Section section = (Section)dstDoc.ImportNode(srcDoc.SectionsIdea [I], true);

dstDoc.Sections.Add(section);

}

}