Code: Select all
Process, Exist, EXCEL.EXE
If !ErrorLevel
Return
Loop
{
XL := ComObjActive("Excel.Application")
For Book in XL.Workbooks
Book.Close(1)
XL.Quit(), XL := ""
Process, Exist, EXCEL.EXE
} Until !ErrorLevel
Code: Select all
Process, Exist, EXCEL.EXE
If !ErrorLevel
Return
Loop
{
XL := ComObjActive("Excel.Application")
For Book in XL.Workbooks
Book.Close(1)
XL.Quit(), XL := ""
Process, Exist, EXCEL.EXE
} Until !ErrorLevel
Remove the 1 from the close line, as that is passing True to save changes. (https://msdn.microsoft.com/en-us/vba/ex ... thod-excel)carno wrote:I understand the following code works to close Excel files and saving them ( http://www.autohotkey.com/board/topic/8 ... workbooks/ ). However, I would like to close several files without saving any of them. Any suggestions?
Code: Select all
Process, Exist, EXCEL.EXE
If !ErrorLevel
Return
Loop
{
XL := ComObjActive("Excel.Application")
For Book in XL.Workbooks
Book.Close() ; Remove the 1 from this line.
XL.Quit(), XL := ""
Process, Exist, EXCEL.EXE
} Until !ErrorLevel
Code: Select all
Process, Close, Excel.exe
Code: Select all
Workbooks("BOOK1.XLS").Close SaveChanges:=False
Users browsing this forum: AHK_user, sharonhuston and 222 guests