4

我有一个用 c# 编写的 Word 到 PDF 转换器,除了一件事外,它工作正常。有时(在某些 Word 文件上)在后台有一条消息,在源文件中保存更改 - > YES NO CANCEL - 但我没有对源文件进行任何更改。我只想从 Word 文件创建一个 PDF 文件,而不做任何更改。

那么是否有可能禁用此提示,或自动设置为“否”。?

这是我的代码:

// Create an instance of Word.exe
        Microsoft.Office.Interop.Word._Application oWord = new  Microsoft.Office.Interop.Word.Application();

        // Make this instance of word invisible
        oWord.Visible = false;

        oWord.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;

        oWord.Options.SavePropertiesPrompt = false;
        oWord.Options.SaveNormalPrompt = false;

        // Interop requires objects.
        object oMissing = System.Reflection.Missing.Value;
        object isVisible = true;
        object readOnly = true;
        object oInput = input;
        object oOutput = output;
        object oFormat = format;

        // Load a document into our instance of word.exe
        Microsoft.Office.Interop.Word._Document oDoc = oWord.Documents.Open(ref oInput, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref isVisible, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

        // Make this document the active document.
        oDoc.Activate();

        // Save this document in Word 2003 format.
        oDoc.SaveAs(ref oOutput, ref oFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

        // Always close Word.exe.
        oWord.Quit(ref oMissing, ref oMissing, ref oMissing);
4

1 回答 1

3

您是否尝试将 false 作为 Quit 的第一个参数传递?

于 2012-10-13T14:55:56.280 回答