Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hello again,
I have a separate function that I need in order to tell how many workbooks are open besides the one I'm currently in. Basically, I want to know this so that when the main Macro ends it checks for this and if there are other workbooks open, it leaves Excel running. If there aren't any other workbooks open, I want to close the Excel application completely. This is currently what I had in mind, but it doesn't work regardless. It gives an error that the "argument is not optional". Function WorkbooksOpen() As Boolean WorkbooksOpen = False If Len(Application.Workbooks.Open) 1 Then WorkbooksOpen = True ' Determines that other workbooks are open ' DON'T close Excel Else ' Determines that other workbooks are NOT open ' DO close Excel End If End Function Any thoughts on this or am I approaching this the wrong way? Is there a better solution? Thanks in advance! |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Why not check the Workbooks.Count property? You'll have to take your active
book into account, any maybe test for personal.xls (don't want to keep Excel open if the only other workbook open is Personal.xls). " wrote: Hello again, I have a separate function that I need in order to tell how many workbooks are open besides the one I'm currently in. Basically, I want to know this so that when the main Macro ends it checks for this and if there are other workbooks open, it leaves Excel running. If there aren't any other workbooks open, I want to close the Excel application completely. This is currently what I had in mind, but it doesn't work regardless. It gives an error that the "argument is not optional". Function WorkbooksOpen() As Boolean WorkbooksOpen = False If Len(Application.Workbooks.Open) 1 Then WorkbooksOpen = True ' Determines that other workbooks are open ' DON'T close Excel Else ' Determines that other workbooks are NOT open ' DO close Excel End If End Function Any thoughts on this or am I approaching this the wrong way? Is there a better solution? Thanks in advance! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do get I my schedule to open at the current date? | Excel Worksheet Functions | |||
When I open Excel, workbooks open automatically. How can I stop t | Excel Discussion (Misc queries) | |||
Macro syntax to open file in current explorer folder | Excel Discussion (Misc queries) | |||
Excel should open documents in the folder of the current file | Setting up and Configuration of Excel | |||
How can I get current cell row number | Excel Discussion (Misc queries) |