How to Insert a new document into any position of a source document?

Dear support,
I use aspose.words.dll v18.7 based on VB.net 2008 to insert a new document into any position of a source document, such as insert it into the head/end or after/before a given paragraph, unfortunately, the dll always output wrong result, the new document always inserted into the end of the source document. How to fix this? or how to reach my goal?
Following is my codes:

    Dim MainDoc =  new Document(MainDocFile)
    Dim MainBuilder =new DocumentBuilder(MainDoc )
    Dim InsertDoc =  new Document(InsertDocFile)
    'Insert the InsertDocFile into the Head of the MainDocFile
    MainBuilder .MoveToDocumentStart()
    MainDoc .AppendDocument(InsertDoc , Global.Aspose.Words.ImportFormatMode.KeepSourceFormatting)
 InsertDoc.save(OutFile)
 'It output wrong result, i.e., the  InsertDocFile has been inserted into the end of the MainDocFile, not the correct position.

'Insert the InsertDocFile into the middle of the MainDocFile,such as before the 5th paragraph
MainBuilder .MoveToParagraph(5,0)
MainDoc .AppendDocument(InsertDoc , Global.Aspose.Words.ImportFormatMode.KeepSourceFormatting)
InsertDoc.save(OutFile)
'It output wrong result, i.e., the InsertDocFile has been inserted into the end of the MainDocFile, not the correct position.

Could you help me to fix this?

Thanks for your help!

Ducaisoft


@ducaisoft,

Please upgrade to the latest version of Aspose.Words for .NET i.e. 19.10 and use the following simple code to insert document at any place in another Word document:

Document doc = new Document("E:\\Temp\\in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("my");

Document docTarget = new Document("E:\\Temp\\insertDocument.doc");
builder.InsertDocument(docTarget, ImportFormatMode.KeepSourceFormatting);

doc.Save("E:\\Temp\\19.10.docx");

P.S. You can easily convert the above C# code to VB.NET yourself by using some converter. For example: Convert C# to VB.NET - A free code conversion tool - developer Fusion