code errors

viper

Active Member
Joined
Feb 15, 2002
Messages
382
Hello all,

I'm using this code I found in my book, but when I use it I get errors of with block variable not set

Here's the code:

Code:
'Get the index of the Help menu

HelpIndex = CommandBars(1).Controls("Help").Index

'Create new control
Set NewMenu = CommandBars(1).Controls.Add(Type:=msoControlPopup, _
Before:=HelpIndex, Temporary:=True)
'add caption
NewMenu.Caption = "Fi&gures"

All I'm wanting to do is create a new control so I can then add menu items under it for my worksheet.

Is there a limit to the number of controls on the standard commandbar?

I currently have the standard items, HTML, Andrews Utilities, and ASAP Utilities.

Thanks,
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Can you post the rest of the code?

What you have posted so far looks fine to me.
 
Upvote 0
Then I'm assuming that's my problem. That's all my code. I don't use more than that when I add menu items to existing controls.

What else do I need.
 
Upvote 0
Sorry, for some reason when I put the code into the Workbook_Open event it wouldn't work and had errors, when I created a separated macro and then ran that from the Workbook_Open event it is now working.
 
Upvote 0

Forum statistics

Threads
1,222,226
Messages
6,164,712
Members
451,911
Latest member
Sam1am

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