Remove mailmerge data source via OpenXML
Posted
by Dan
on Stack Overflow
See other posts from Stack Overflow
or by Dan
Published on 2010-03-23T17:22:01Z
Indexed on
2010/03/23
18:53 UTC
Read the original article
Hit count: 587
I have some code that uses OpenXML to open up a docx file, find all mailmerge fields, and replace them with data (ignoring the datasource that may have been provided).
I initially tested this against a document created in Office 2007 and it seemed to work great.
We then created one in 2003 based off an Excel spreadsheet data source and saved it to 2007 docx format. When we open the file produced by my code, Word warns the user that it is going to execute some SQL, specifically "SELECT * from 'Sheet1$'". It has options of Yes/No. Selecting Yes requires I find the data source. Selecting No brings me to the document, which appears to be correct.
I'm not sure why I'm now seeing this pop up. Perhaps it's due to a different data source for the 2003 document?
My hope was that there was a way to delete all references to any datasources and that the pop-up wouldn't show. I found this, but it doesn't seem to work. Any suggestions?
© Stack Overflow or respective owner