Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I currently use:
Sub Button14_Click() Application.DisplayAlerts = Fasle ActiveWorkbook.Save ActiveWorkbook.Close Application.DisplayAlerts = True End Sub Is there a way for Excel to Check if ANY other Workbooks are Open or Not. If NO others are Opened, then to QUIT rather than to CLOSE ??? But if there is another Workbook open then Excel simply Closes this Workbook an NOT Quitting Excel. Can you do this? Corey.... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Corey,
You can check the Workbooks collection, allowing for the WB that contains this code and the possibility of hidden workbooks, notably Personal.xls. something based on: Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim WB As Workbook For Each WB In Application.Workbooks Debug.Print WB.Name If WB.Name < ThisWorkbook.Name Then If WB.Windows(1).Visible = True Then Exit Sub End If Next Application.Quit End Sub NickHK "Corey" wrote in message ... I currently use: Sub Button14_Click() Application.DisplayAlerts = Fasle ActiveWorkbook.Save ActiveWorkbook.Close Application.DisplayAlerts = True End Sub Is there a way for Excel to Check if ANY other Workbooks are Open or Not. If NO others are Opened, then to QUIT rather than to CLOSE ??? But if there is another Workbook open then Excel simply Closes this Workbook an NOT Quitting Excel. Can you do this? Corey.... |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank You Nick.
Perfectly done.. "NickHK" wrote in message ... Corey, You can check the Workbooks collection, allowing for the WB that contains this code and the possibility of hidden workbooks, notably Personal.xls. something based on: Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim WB As Workbook For Each WB In Application.Workbooks Debug.Print WB.Name If WB.Name < ThisWorkbook.Name Then If WB.Windows(1).Visible = True Then Exit Sub End If Next Application.Quit End Sub NickHK "Corey" wrote in message ... I currently use: Sub Button14_Click() Application.DisplayAlerts = Fasle ActiveWorkbook.Save ActiveWorkbook.Close Application.DisplayAlerts = True End Sub Is there a way for Excel to Check if ANY other Workbooks are Open or Not. If NO others are Opened, then to QUIT rather than to CLOSE ??? But if there is another Workbook open then Excel simply Closes this Workbook an NOT Quitting Excel. Can you do this? Corey.... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Open workbook on close | Excel Programming | |||
my password quit working in an excel workbook, help! | Excel Worksheet Functions | |||
macro to close excel application other than application.quit | Excel Programming | |||
Close Open Woorkbook and Quit Excel | Excel Programming | |||
EXCEL.exe stays open after Quit method in an HTA | Excel Programming |