I have created a menu for my Excel macro workbook, but there is an instance where I would want most of the items listed in the menu to be either disabled/greyed out/invisible. I have been trying to write the code to do this, but can't quite figure out the syntax. I've searched around online, but haven't come across anything yet that gave me the solution.
Here's part of my code that runs on Workbook_Open:
(This isn't the entire code that creates the menu, but that is quite long, so I didn't put it all here. The menu definitely is created and works fine, though. Let me know if you would like to see the entire code for creating the menu, and I will post it.)
Later in my code when I want to make this disabled, here is the line of code I currently have:
This line throws an error: Run-time error 91 - Object variable or With Block Variable Not Set
Anyone know what I'm missing here?
Here's part of my code that runs on Workbook_Open:
Code:
Set objBtn = objPopUp.Controls.Add
With objBtn
.Caption = "Globals"
.Tag = "Globals"
.OnAction = "Globals_Button"
.Style = msoButtonCaption
End With
(This isn't the entire code that creates the menu, but that is quite long, so I didn't put it all here. The menu definitely is created and works fine, though. Let me know if you would like to see the entire code for creating the menu, and I will post it.)
Later in my code when I want to make this disabled, here is the line of code I currently have:
Code:
Application.CommandBars.FindControl(Tag:="Globals").Enabled = False
This line throws an error: Run-time error 91 - Object variable or With Block Variable Not Set
Anyone know what I'm missing here?
Last edited: