How to turn off Word warning messages? lazarus / 34-Windows ---------------------------------------------------------------------- loaded · 2021-10-06 05:50 Hi All, When I close Excel after creating a new document and adding content in Excel, the process results as I want without any warning. But when I create a document in Word, add content and then close the document, the "Save Changes" dialog box appears. It turns out that the ...DisplayAlerts statement works in Excel, but has no effect on Word!!! What else can be done about the subject? Sample code snippet; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var  Excel:olevariant; //add uses comobjbegin  Excel:=CreateOleObject('Excel.Application');  Excel.Visible:=True;  Excel.displayalerts:=false;  // effective  Excel.Workbooks.Add;  Excel.ActiveSheet.Cells[1,1]:='Dede';end; procedure TForm1.Button2Click(Sender: TObject);var  Word,Prg:olevariant; //add uses comobjbegin  Word := CreateOleObject('Word.Application');  Word.Visible := True;  Word.DisplayAlerts := false;  //ineffective  Word.Documents.Add;  Prg := Word.ActiveDocument.Content.Paragraphs.Add;  Prg.Range.Text := 'Dede';end; ---------------------------------------------------------------------- noszone · 2021-10-06 08:22 Check this out first: https://stackoverflow.com/questions/47866522/saving-a-word-document- and-setting-displayalerts-to-disable-prompt-to-save Pay attention to last message in thread. Then this: https://forum.lazarus.freepascal.org/index.php/topic,56550.msg420751.h tml#msg420751 The idea of this to disable review mode, if enabled. Hope it helps somehow. ---------------------------------------------------------------------- loaded · 2021-10-06 08:54 Thank you very much for the quick reply noszone, I checked the links, unfortunately there is no solution for now. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Private Sub CommandButton1_Click()Dim oWord As Word.ApplicationSet oWord = New Wor d.ApplicationoWord.Documents.AddoWord.Options.WarnBeforeSavingPrinting SendingMarkup = FalseoWord.Visible = TrueIf oWord.Options.WarnBeforeSavingPrintingSendingMarkup Then MsgBox "Aktif" Else MsgBox "Pasif"End Sub Even the code I run with vba from within word cannot turn off the warnings. ---------------------------------------------------------------------- noszone · 2021-10-06 09:19 Are you sure that used the: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Word.ActiveDocument.Save; ---------------------------------------------------------------------- loaded · 2021-10-06 09:46 For work, I create continuously variable word files, send to printer and that's it, I don't need to save to disk. If I had to save it to disk there would be no problem. However, when I use the Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i oWord.ActiveDocument.Save code, the save dialog box appears. ---------------------------------------------------------------------- Thaddy · 2021-10-06 09:50 Yes. Tested. But that is a Microsoft issue and does not belong on THIS forum. Ask Microsoft. ---------------------------------------------------------------------- Zvoni · 2021-10-06 10:11 RTFM https://docs.microsoft.com/en-us/office/vba/api/word.document.save QuoteRemarks If a document has not been saved before, the Save As dialog box prompts the user for a file name.If you just want to close Word without saveing, use Quit https://docs.microsoft.com/en- us/office/vba/api/word.application.quit(method) ---------------------------------------------------------------------- Thaddy · 2021-10-06 10:20 How I read this is simply allow the save but do not show the dialog. ---------------------------------------------------------------------- ccrause · 2021-10-06 10:23 The document.close method takes optional parameters, the first of which is called SaveChanges, which you can set to wdDoNotSaveChanges. ---------------------------------------------------------------------- Zvoni · 2021-10-06 10:36 Quote from: Thaddy on October 06, 2021, 12:20:48 pmHow I read this is simply allow the save but do not show the dialog. Not quite. The only way to escape the SaveAs-Dialog for an unsaved and untitled document is to check if it has been already saved once, and then to provide the filename in a (separate) SaveAs2-Call ---------------------------------------------------------------------- Zvoni · 2021-10-06 10:37 Quote from: ccrause on October 06, 2021, 12:23:24 pmThe document.close method takes optional parameters, the first of which is called SaveChanges, which you can set to wdDoNotSaveChanges. This doesn't close the Word-Application, just the document ---------------------------------------------------------------------- loaded · 2021-10-06 10:55 Thaddy,Zvoni and ccrause thank you very much for the reply. I had a similar problem with Lazarus and VB6 before. Naturally, when the problem occurred, I initially thought there was a problem with the component object model. But when I went deeper, I saw that WORD was about itself. Quote from: Thaddy on October 06, 2021, 11:50:36 amYes. Tested. But that is a Microsoft issue and does not belong on THIS forum. Ask Microsoft. You're right Thaddy, the problem is windows, but if you don't mind, let's not delete the message, maybe it will make someone like me wake up early to such an error.