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

Free Support Forum - aspose.com

How to insert new document at the head or end of the main document?

Hi, support,

I want to insert an existing document into the head or end of the main document?
How to work it out by aspose.words.dll and VB.net?

Thanks for your help!


Thanks for your inquiry. You need to move the cursor to the document’s start and end and insert the document using DocumentBuilder.InsertDocument method.

Below code example shows how to insert the document to the end of another document. Hope this helps you.

Dim doc As Document = New Document(MyDir & "Document.docx")
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
Dim docToInsert As Document = New Document(MyDir & "DocumentBuilder.KeepSourceFormatting.docx")
builder.InsertDocument(docToInsert, ImportFormatMode.KeepSourceFormatting)
doc.Save(MyDir & "out.docx")