ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   prevent second copy from opening (https://www.excelbanter.com/excel-programming/271344-re-prevent-second-copy-opening.html)

Tom Ogilvy

prevent second copy from opening
 
Basically, is there a way to check if a workbook with the
same name is already opened and if it is, do not try to
open a new instance.


You can't have two workbooks open with the same name.

You could have your workbook open event see if a version of the menu is
already present.

On error resume next
set obar = Commandbars("Worksheet Menu Bar").Controls("My Menu")
On Error goto 0
if obar is nothing then
' create the meny
End if



Regards,
Tom Ogilvy

"Derek" wrote in message
...
I have a workbook that uses the workbook_open event to
call a procedure to create a menu. When I try to open a
second instance of the workbook I get an error. It looks
like the second workbook is trying to create the menu
again (I am assuming there is a name conflict).

Basically, is there a way to check if a workbook with the
same name is already opened and if it is, do not try to
open a new instance.





All times are GMT +1. The time now is 05:34 PM.

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