Hey, everyone,
I want to use COM .SaveAs on a excel file but I do not want to be prompted on whether I want to save the file but I simply want it to overwrite the existing file. Is there any way to do this?
Thanks!
COM .SaveAs Overwrite file
Re: COM .SaveAs Overwrite file
Hello ShubhamM.
You can disable warnings by setting DisplayAlerts to false.
Example (Code below DOES NOT prompt a overwrite warning):
If you remove the line Xl.DisplayAlerts := False IT WILL prompt an overwrite alert if there is a file with that name. Also, if AutoHotkey lacks permission to modify the file, this will prompt an error (Example: if the file is already opened in excel and you try to save some other file with that name while it is open you will get an error and the file WILL NOT be saved).
Best wishes.
You can disable warnings by setting DisplayAlerts to false.
Example (Code below DOES NOT prompt a overwrite warning):
Code: Select all
Xl := ComObjCreate("Excel.Application")
Xl.Workbooks.Add ;add a new workbook w/ standard 3 sheets
Xl.Visible := True
Xl.DisplayAlerts := False
Xl.ActiveWorkbook.SaveAs(A_SCriptDir . "\UniquelyNamedSheet", 51)
Best wishes.
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Re: COM .SaveAs Overwrite file
You're the best, Gio! Thanks a lot for this! It works like a charm!