Template Document Locked while doing mail merge

I am running into an issue, where when I am mail merging, the template document is locked for the duration of the merge.  Is there a way to work with the document without actually opening it and locking it?

using (var fileStream = File.Open(templateFile, FileMode.Open)) {
                var document = new WordDocument(fileStream, formatType);
                var mergeTable = new MailMergeDataTable(dataName, data);

                document.MailMerge.MergeField += new MergeFieldEventHandler(MergeField_InsertPageBreak);

                document.MailMerge.ExecuteNestedGroup(mergeTable);

                if (_stream == null) {
                    _stream = new MemoryStream();
                }

                RemoveEmptyPage(ref document);

                document.Save(_stream, formatType);
                document.Close();

                _stream.Position = 0;
                return _stream;
            }

3 Replies

MR Manikandan Ravichandran Syncfusion Team February 12, 2020 01:40 PM UTC

Hi Aaron,

Thank you for contacting Syncfusion.

We are unable to reproduce the mentioned issue at our end using the given details. So, kindly provide us the complete runnable sample, input document and generated output document to reproduce the mentioned issue, so that we can proceed further to analyse and update you with the appropriate details.

Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face.

Please let us know if you have any further questions.

Regards,
Manikandan Ravichandran



AA Aaron February 13, 2020 09:37 PM UTC

We were able to figured out the problem. I was using File.Open instead of File.OpenRead.  


VA Vijayasurya Anandhan Syncfusion Team February 14, 2020 01:34 PM UTC

Hi Aaron,

Thank you for your update and confirmation.

 
We are glad to know that the reported problem gets resolved. Please let us know if you need further assistance in this. As always, we will be happy to assist you. 

Regards,
Vijayasurya A


Loader.
Up arrow icon