» Change the availability for a menu item using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Menus, Toolbars, Status bar in VBA
VERSION - All Microsoft Excel Versions
The macro below shows how you can toggle the availability state for a menu item.
Sub ToggleMenuControls()
Dim m As CommandBarControl, mi As CommandBarControl
Set m = CommandBars.FindControl(ID:=30002) ' File Menu
If m Is Nothing Then Exit Sub
For Each mi In m.Controls
If mi.ID = 18 Then mi.Enabled = Not mi.Enabled
' toggles the state for the Print menu
Next mi
Set mi = Nothing
Set m = Nothing
End Sub
Book Store:
Recommended Books:
- Microsoft Office XP Step-By-Step (With CD-ROM)
- Marketing Plan: A Handbook with Marketing Plan
- The McGraw-Hill Guide to Writing a High-Impact Business Plan: A Proven Blueprint for First-Time Entrepreneurs
- A Mathematician Plays the Stock Market
- Harry Potter and the Order of the Phoenix (Book 5)
- Absolute Beginner's Guide to Microsoft Excel 2002
No comments have been submitted.

