![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Hello.
I have a situation I have a Macro that loads a form where the user can choose what type of data he wants to load, the just has to click on the appropriate button and the data will be loaded. One of the buttons is labelled 'Exit' and what this does is close Excel altogehter. I use Application.Quit as the command A colleague put a case forward that if the User has the Makro open and he decides to open a standard excel file, and then he chooses to exit the Makro, then both files will close because of the command Application.Quit I would like the program to run so that when the Makro is loaded without any additional Excel files being opened and the user clicks on 'Exit' that Excel will close. But if an additional file is already open and the user loads the Makro and then decides to 'Exit' is it possible to check wether there are any Workbooks other than the Makro workbook present ?if so then only do an Activewindow.Close, if not then use the Application.Quit Does anybody know how to put that into code? I would be grateful for any help you can give. Thanks. |
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
How about this?
Code:
If Excel.Workbooks.Count > 1 Then 'More than one workbook open
ThisWorkbook.Close
Else
Application.Quit
End If
D [ This Message was edited by: dk on 2002-03-07 09:40 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|