2014-09-04 58 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提供的鏈接,有固定的問題。