2014-09-04 27 views
0

我转换了大量的MS Word文档中使用的Interop库在多线程WPF应用程序PDF文件(.NET Framework 4的)。我得到一些word文档以下错误:获得“隐藏模块中的编译错误:SmartTagsMod”,而在MS Word中打开一个Word文档2010

Screenshot of the error http://i60.tinypic.com/4fz9co.png

它会阻止当前线程,直到我点击确定关闭对话框,然后继续转化率和转换的PDF出来要罚款为好。

这只发生在某些文件上。我在多台计算机上运行该应用程序,这也发生在其他计算机上。

下面是我的转换代码:

var wordApplication = new Microsoft.Office.Interop.Word.Application(); 
// Opening the word document 
var wordDocument = wordApplication.Documents.Open(tempFile, false, true, false, NoEncodingDialog: false); 
// Exporting the document to the PDF 
wordDocument.ExportAsFixedFormat(pdfPath, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF); 
// Closing the document and the application. 
((Microsoft.Office.Interop.Word._Document)wordDocument).Close(false); 
((Microsoft.Office.Interop.Word._Application)wordApplication).Quit(false); 
Marshal.ReleaseComObject(wordDocument); 
Marshal.ReleaseComObject(wordApplication); 
wordDocument = null; 
wordApplication = null; 

有谁知道什么可能会造成这个?或者我是否可以从我的应用程序关闭此对话框?

感谢

+0

http://stackoverflow.com/questions/6224592/how-to-stop-macros-running-when-opening-a-word-document-using-ole-interop可能是有用的 – 2014-09-04 17:09:20

+0

是的,其中一个建议修复程序为我工作。非常感谢。 – 2014-09-05 09:33:26

回答

0
wordApplication.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable; 

这似乎已经解决了这一问题。

感谢bibadia提供的链接,有固定的问题。