How can I force a workbook to close?
Hi Ryan,
Run this code and enjoy.
Sub Macro1()
Windows("MainFile.xls").Activate
ActiveWorkbook.Close
End Sub
On 22 Лип, 21:07, ryguy7272 wrote:
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 doesnt 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--
|