ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Evaluate Open Files / multiple instances open (https://www.excelbanter.com/excel-programming/386493-evaluate-open-files-multiple-instances-open.html)

Troubled User

Evaluate Open Files / multiple instances open
 
I have a custom menu bar that gets activated when the file is open and gets
reset when the file is closed. Problem is the user is now telling me they
may have multiple instances of the same file open at one time.

I altered the Add code to reset before adding, so that only one set of the
menubar was open. This seems to work fine, problem is on the close event I
need to evaluate if multiple sheets (of this type) are open and then skip the
Reset (Application.CommandBars(1).Reset) on the close, if it is not the last
sheet of this kind open. Any ideas?


JLGWhiz

Evaluate Open Files / multiple instances open
 
You could put an exception type If ... Then statement in like if the open
sheets are < 2 then do the reset command. That way if more than one sheet is
open it won't reset.

"Troubled User" wrote:

I have a custom menu bar that gets activated when the file is open and gets
reset when the file is closed. Problem is the user is now telling me they
may have multiple instances of the same file open at one time.

I altered the Add code to reset before adding, so that only one set of the
menubar was open. This seems to work fine, problem is on the close event I
need to evaluate if multiple sheets (of this type) are open and then skip the
Reset (Application.CommandBars(1).Reset) on the close, if it is not the last
sheet of this kind open. Any ideas?


Troubled User

Evaluate Open Files / multiple instances open
 
Ok, I think I just found something else out. I am loading this in the Open
command When I add the menu item to the top, they point to the macros in
that file. Therefore, if I add menu item 1 in file 1 and it is visible in
file 2, when I try to run it in file 2 it is pointing at the macro in file 1.
I am going to change it so that the add code is in the Open event and the
activate event and run the reset in the beforeclose and deactivate. I think
I have got it working.



"Troubled User" wrote:

I have a custom menu bar that gets activated when the file is open and gets
reset when the file is closed. Problem is the user is now telling me they
may have multiple instances of the same file open at one time.

I altered the Add code to reset before adding, so that only one set of the
menubar was open. This seems to work fine, problem is on the close event I
need to evaluate if multiple sheets (of this type) are open and then skip the
Reset (Application.CommandBars(1).Reset) on the close, if it is not the last
sheet of this kind open. Any ideas?


NickHK

Evaluate Open Files / multiple instances open
 
Not sure I follow the multiple instance problem.
You cannot open the same file in the same instance of Excel more than once.
If they have changed the filename, then technically it's not the same file.
However, if the menu bar is only applicable to that one file, use the
WB_Activate/Deactivate events to show/hide it.

NickHK

"Troubled User" wrote in message
...
I have a custom menu bar that gets activated when the file is open and

gets
reset when the file is closed. Problem is the user is now telling me they
may have multiple instances of the same file open at one time.

I altered the Add code to reset before adding, so that only one set of the
menubar was open. This seems to work fine, problem is on the close event

I
need to evaluate if multiple sheets (of this type) are open and then skip

the
Reset (Application.CommandBars(1).Reset) on the close, if it is not the

last
sheet of this kind open. Any ideas?





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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com