Checking for a Menu Control

viper

Active Member
Joined
Feb 15, 2002
Messages
382
I have a spreadsheet that adds a new control called Figures upon opening and then it deletes it upon closing.

What I'm wanting to do is be able to check for that control in the workbook_activate event, if it's there then do nothing, if not then add it.

The reason being, I have 9 of these workbooks that get sent out, when I receive all 9 back and open two or more at the same time, I don't want the control to be deleted when I close one of the workbooks.

So I figure if I can check it in the activate_event, when I close one workbook and it deletes it, when the next one is activated it will add it back.

Is there a way to check to for menu controls?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You didn't specify where the control is, so use the following as an example:

Code:
Private Sub Workbook_Activate()       'Executed after 'Workbook_Open'

'Test if another workbook that uses the control is open by making the
'control visible.  If an Err.Number is generated, no other workbook
'using the control is open so it must be created, otherwise it's made visible
On Error Resume Next
Application.CommandBars("Worksheet Menu Bar").Controls("MyControl").Visible = True
If Err.Number <> 0 Then
'...'MyControl' menu does not exist, so create it
    'code to create here
End If
'continue doing whatever here

Of course, now you'll need to make the control hidden when you deactivate the workbook...

Regards, John
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top