How to disable "Stored document contains tracked changes" Word dialog using C #

Microsoft.Office.Interop.Word.ApplicationClass msDoc = new Microsoft.Office.Interop.Word.ApplicationClass(); msDoc.Visible = false; msDoc.Application.Visible = false; msDoc.Documents.Open(ref docPath, ref UNKNOWN, ref READ_ONLY, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN); msDoc.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMinimize; object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF; msDoc.ActiveDocument.SaveAs(ref target, ref format, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN, ref UNKNOWN); 

The problem is that when you run SaveAs, a dialog box opens. I am trying to disable this dialog programmatically so that the user never provides the Office / Word login or configuration. The utility I am writing could potentially have 100 seconds to save, so the popup dialog is not good.

+4
source share
2 answers

I managed to figure out a software solution by setting the following parameter in my code:

 msDoc.Options.WarnBeforeSavingPrintingSendingMarkup = false; 

Configuration wise I found that you can also disable this Office feature by going to:

Word Options-> Trust Center-> Privacy Settings-> Uncheck the box next to “Warn me before printing, saving, or sending a file containing tracked changes or comments”

+11
source
 msDoc.Options.WarnBeforeSavingPrintingSendingMarkup = false; 

or

Word Options-> Trust Center-> Privacy Settings-> Uncheck the box next to “Warn me before printing, saving, or sending a file containing tracked changes or comments”

not working for me.

What works for me:

msDoc.ActiveWindow.Close (WdSaveOptions.wdDoNotSaveChanges);

+2
source

Source: https://habr.com/ru/post/1340852/


All Articles