MailMerge from word document

Hi there,
I have about 9000 old Word 97 documents with attached data sources. The data sources are also Word 97 documents. I have a table containing the paths to the main documents and their corresponding datasources. Is there any way I can use Aspose to perform the merge?

@tomddlc Could you please attach your sample template and data here for testing? We will check them and provide you more information or a code example.

Great!

Here you go
Mergefiles.zip (10.1 KB)

Thanks

@tomddlc Thank you for additional information. You can use code like the following to extract data from the data document and use them as data for mail merge.

// Open document with data.
Document data = new Document(@"C:\Temp\data_000003.doc");

// There are two paragraphs, the first is a semicolon separated field names,
// the second is a semicolon separated field values.
// Extract these data into arrays.
string[] fieldNames = data.FirstSection.Body.Paragraphs[0].ToString(SaveFormat.Text).Split(';')
    .Select(s => s.Trim('\r', '\n')).ToArray();

string[] fieldValues = data.FirstSection.Body.Paragraphs[1].ToString(SaveFormat.Text).Split(';')
    .Select(s => s.Trim('"', '\r', '\n')).ToArray();

// Open template document
Document doc = new Document(@"C:\Temp\000003.doc");
// Execute mail merge.
doc.MailMerge.Execute(fieldNames, fieldValues);
// Save the result.
doc.Save(@"C:\Temp\out.docx");

Thanks a lot!

I am calling this from within an ERP system (Microsoft Dynamics NAV), so I am a little limited in how long “nested” calls I can make, but you have surely set me down a path I can explore!

Alexey, you are my new best friend!!!

It works now

@tomddlc It is perfect that you managed to achieve what you need. Please feel free to ask in case of any issues, we will be glad to help you.