R
ryguy7272
How can I force a workbook to close?
I run this code:
ThisWorkbook.EnableAutoRecover = False
ThisWorkbook.Saved = True
ThisWorkbook.Close
That triggers this:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.name = "MainFile.xls" Then
Application.Quit
End If
End Sub
But that kills the whole Excel-application! If I open Excel and then
goto Start > Office > Excel, I have 2 instances of Excel open. I can
end one instance pretty easy. However, if I have two workbooks open
within the SAME instance, Excel doesn’t seem to be able to close one
file and keep the other open. In fact, Excel opens several new files,
all named ‘MainFile.xls’. VERY ANNOYING!!!
How can I shut down any file named ‘MainFile.xls’ and keep other Excel
files open?
Thanks!
Ryan--
I run this code:
ThisWorkbook.EnableAutoRecover = False
ThisWorkbook.Saved = True
ThisWorkbook.Close
That triggers this:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.name = "MainFile.xls" Then
Application.Quit
End If
End Sub
But that kills the whole Excel-application! If I open Excel and then
goto Start > Office > Excel, I have 2 instances of Excel open. I can
end one instance pretty easy. However, if I have two workbooks open
within the SAME instance, Excel doesn’t seem to be able to close one
file and keep the other open. In fact, Excel opens several new files,
all named ‘MainFile.xls’. VERY ANNOYING!!!
How can I shut down any file named ‘MainFile.xls’ and keep other Excel
files open?
Thanks!
Ryan--