Reputation: 14904
I have a Word to PDF Converter written in c# which works fine except of one thing. Sometimes (on some Word Files) there is a Message in Background with Save Changes in Source File -> YES NO CANCEL - but I dont do any changes in Source file. I just wanna create a PDF File from the Word File, without changing anything.
So is there a Possibility to disable this Prompt, or set automatically to "NO". ?
Here is my Code:
// 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);
Upvotes: 4
Views: 2645