enabling custom meu items?

  • Thread starter Thread starter John
  • Start date Start date
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
 
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
 
Back
Top