object variable not set with commandbars

I

icccapital

I have the following code in my workbook_open procedure:
CommandBars("worksheet menu bar").Controls().Add(Type:=msoControlPopup,
before:=CommandBars("worksheet menu bar").Controls.Count + 1,
temporary:=True).Caption = "Client Reports"

So I am basically trying to add a menu item to "worksheet menu bar". It
worked fine when I tested it in a module after the workbook had opened, but
when I added it to the workbook_open procedure and reopened the workbook I
get this error. I also get it on commandbars(0).name, so are the commandbars
not loaded yet? Is there a way to load them? Thank you.
 
J

Jim Cone

Use: Application.CommandBars
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"icccapital" <[email protected]>
wrote in message
I have the following code in my workbook_open procedure:
CommandBars("worksheet menu bar").Controls().Add(Type:=msoControlPopup,
before:=CommandBars("worksheet menu bar").Controls.Count + 1,
temporary:=True).Caption = "Client Reports"

So I am basically trying to add a menu item to "worksheet menu bar". It
worked fine when I tested it in a module after the workbook had opened, but
when I added it to the workbook_open procedure and reopened the workbook I
get this error. I also get it on commandbars(0).name, so are the commandbars
not loaded yet? Is there a way to load them? Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top