【问题标题】:Getting 'Compile error in hidden module: SmartTagsMod' while opening a word document in MS Word 2010在 MS Word 2010 中打开 Word 文档时出现“隐藏模块中的编译错误:SmartTagsMod”
【发布时间】:2014-09-04 13:56:44
【问题描述】:

我正在使用多线程 WPF 应用程序 (.NET Framework 4) 中的互操作库将大量 MS Word 文档转换为 PDF。我在某些 word 文档中收到以下错误:

它会阻止当前线程,直到我在对话框上单击“确定”,然后继续转换,转换后的 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;

有人知道是什么原因造成的吗?或者我是否可以从我的应用程序中关闭此对话框?

谢谢

【问题讨论】:

标签: c# wpf multithreading ms-word office-interop


【解决方案1】:
wordApplication.AutomationSecurity = Microsoft.Office.Core.MsoAutomationSecurity.msoAutomationSecurityForceDisable;

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

感谢 bibadia 提供已修复问题的链接。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-16
    • 1970-01-01
    • 1970-01-01
    • 2021-08-02
    • 2020-09-29
    • 1970-01-01
    • 2016-01-01
    • 1970-01-01
    相关资源
    最近更新 更多