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

Free Support Forum - aspose.com

Is it possible to copy a word file and append it to the end of another?

Hi,

If I have a word template file that I am using for mail merge, is it possible for me to perform the mail merge for one set of data, and then perform it again for a second set of data,
and then finally append the 2 together to create a single document?

I am trying this at the moment by Creating 2 Document objects and calling .AppendDocument on the first one to add the second, but it isn't working - I just have a document with the results of the first merge.

Code sample looks like this:

var page1 = new Document(_pathName);
page1.MailMerge.Execute(table1);

// now add page 2:
var page2 = new Document(_pathName); // Same source file as the origninal.
page2.MailMerge.Execute(table2);

// The following line makes no difference
page1.AppendDocument(page2, ImportFormatMode.UseDestinationStyles);


Thanks

Hi

Thanks for your request. AppendDocument should work for you. Do you save the output as PDF? If so, please try calling UpdatePageLayout before saving the document:

doc.UpdatePageLayout();

doc.Save(@"c:\Temp\output.pdf");

Hope this helps.

Best regards,

Thanks, that seems to work, along with using the .clone method to copy the document in the first instance.