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

Free Support Forum - aspose.com

Merging Word Document Section is not working


I have the following code for merge multiple documents

Document doc = new Document();
Document doc1 = new Document(@"C:\Documents and Settings\Desktop\Test1.docx");
Document doc2 = new Document(@"C:\Documents and Settings\Desktop\Test2.docx");
Section section=new Section(doc1);
Section newSection = (Section)doc.ImportNode(section, true, ImportFormatMode.KeepSourceFormatting);
Section section1 = new Section(doc2);
Section newSection1 = (Section)doc.ImportNode(section1, true, ImportFormatMode.KeepSourceFormatting);
doc.Save(@"C:\Documents and Settings\Desktop\Test3.docx");

Here am trying to merge doc1 and doc2 into doc

Am facing the following issues

1. In result "doc" am getting blank page in the begining

2. The doc2 contents are not displaying in final word out put

Please tell me where are doing wrong or please tell me how to merge multiple Documents into one final word document



I think you’ll find the answer your looking for here.

Hi Ajeesh,

Thanks for your inquiry. Could you please attach your input Word documents here for testing? I will investigate the issues on my side and provide you more information.

Best regards,

Hi Awais Hafeez

Thanks for your reply

I got the solution for my problem in the previous mail.Now i have another query

I have one word template and i have a Dataset.In the dataset i have multile datatabe.Using one word template how to replace all the datatables in the dataset.Am using doc.MailMerge.ExecuteWithRegions method to bind.Am attaching my template here .I need Each datatable in dataset to be display in different pages



Hi Ajeesh,

Thanks for your inquiry. There is only one MailMerge Region in your Template Word document (i.e. ReportTable); could you please clarify how exactly you require all the records in every DataTable of DataSet be merged in this single Region? May be you can take union of all Rows in DataTables and create a one big DataTable with the same name (ReportTable) as of your MailMerge Region. You can then use the following overload of ExecuteWithRegions method to perform mail merge from a DataTable into the document with mail merge regions

public void ExecuteWithRegions(DataTable);

Best regards,