LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default How can I force a workbook to close?

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--
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Force Excel to close Nigel Excel Programming 6 June 1st 09 03:25 PM
How to force Excel wkbk to close JoAnn Excel Programming 2 September 29th 08 06:24 PM
How do you force excel to save on close Tom Hewitt Excel Discussion (Misc queries) 3 September 21st 06 10:55 AM
Is there a way to force Excel to close workbooks independently? Cam Excel Discussion (Misc queries) 4 February 2nd 06 07:43 PM
Force a Message Box to close unanswered jennie Excel Programming 1 October 12th 05 10:23 AM


All times are GMT +1. The time now is 10:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"