开发者

Remove MailMerge data source via OpenXML

开发者 https://www.devze.com 2022-12-23 17:48 出处:网络
I have some code that uses Open XML to open up a .docx file, find all MailMerge fields, and replace them with data (ignoring the datasource that may have been provided).

I have some code that uses Open XML 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 agains开发者_JS百科t 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?


Ok, I found out how to do this. Had to get the settings part from /word/settings.xml, find the w:mailMerge entry and delete it.

0

精彩评论

暂无评论...
验证码 换一张
取 消