enabling custom meu items?

J

John

Dear all
I have custom menu that works OK but I do not seem to be
able to disable or enable seperate menu items.
I tried the following code but this gives an error message:

Menu bar item: TPBQ

Sub DisMenuItems()
Dim TPBQMenu As CommandBarPopup
Set TPBQMenu = CommandBars(1).FindControl
(Type:=msoControlButton, ID:=CommandBars(1).Controls
("TPBQ").ID)
TPBQMenu.Controls("&Export...").Enabled = False
End Sub

Error message:
Runtime error 91:
Object variable or with block variable not set

I am using excel 2002 on win 2000

Any help would be really apppreciated

Kind regards,

John
 
B

Bernie Deitrick

John,

Since you named the control, you can simply use:

Sub hideAbout()
Dim TPBQMenu As CommandBarPopup
Set TPBQMenu = CommandBars(1).Controls("&TPBQ")
TPBQMenu.Controls("&About TPBQ...").Enabled = False
End Sub

Sub showAbout()
Dim TPBQMenu As CommandBarPopup
Set TPBQMenu = CommandBars(1).Controls("&TPBQ")
TPBQMenu.Controls("&About TPBQ...").Enabled = True
End Sub

HTH,
Bernie
Excel MVP
 

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

Similar Threads


Top