Aspose.Words Mail Merge issue with Office 2007

Hi
I’ve just downloaded Aspose.Words for .NET 5.2.2 to try out its MailMerge functions.
The mail merge works greate apart from outputing document as a .docx
when I attempt to open my mail merged .docx file, I always get the “The file is corrupt and cannot be opened.” error pop-up.
I clicked OK and then it another pop-up ask if I want to recove the contents. I click Yes and then everything works fine. All my merge fields are merge the way I want also.
Is there anyway we can do this without getting the pop-up error and have to recover the document before viewing?
regards
-andy

Hi
Thanks for your inquiry. Could you please attach your template for testing and provide me your code? I will investigate this problem and provide you more information.
Best regards.

Thanks for your quick reply.
please see the attached for my mail merge template.
here’s my code:

// Open document template 
Document doc = new Document(@"C:\Documents and Settings\Administrator\Desktop\Test.docx");
// Fill the fields in the document with user data.
doc.MailMerge.Execute(
new string[] { "Appointment Title" },
new object[] { "***Test Appointment Title***"});
// Send the document in Word format to the client browser
doc.Save(
outputDocTitle,
SaveFormat.Docx,
SaveType.OpenInBrowser,
Response);

Hi

Thanks for your request. I think that you should call Respons.End() after saving document. Please try using the following code.

doc.Save("out.docx", SaveFormat.Docx, SaveType.OpenInWord, Response);
Response.End();

Hope this helps.
Best regards.

it works!
thanks very much :slight_smile: