Hi All
I am in the process of evaluating Aspose.Words and Cells version 16.11.0.0 for .Net 4.0 and was trying to get Word Mailmerge running using Excel as a datasource. I found the following code on one of the posts, but I am having a problem getting it to work. The final Doc2_Out.docx has not mailmerged the data. When I try to open it I get the attached message, Message.jpg.
Anyone any ideas what I am missing here.
Am I correct in saying the Save method of the Document Class will execute the Mailmerge to the specified new document.
I have attached the Word Document and Excel file I am using for the mailmerge. If I perform the mailmerge with these files, manually or via automation, using Microsoft word, the mailmerge works without any issues.
I put the following code in the click method of a windows forms C# sample application.
Document doc = new Document(@"C:\Temp\Doc2.docx");
string excelDS = @"c:\Temp\Book2.xlsx";
MailMergeSettings mms = doc.MailMergeSettings;
mms.DataSource = excelDS;
mms.MainDocumentType = MailMergeMainDocumentType.FormLetters;
mms.DataType = MailMergeDataType.Spreadsheet;
mms.LinkToQuery = true;
mms.ViewMergedData = true;
mms.Query = "SELECT * FROM " + mms.DataSource;
doc.Save(@"c:\Temp\Doc2_out.docx");
Any help would be greatly appreciated
Regards,
David