» 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:
- Writing Excel Macros with VBA, 2nd Edition
- Business Analysis with Microsoft Excel (2nd Edition)
- Investments + S&P Card + Powerweb + StockTrak discount coupon
- Flipping Properties: Generate Instant Cash Profits in Real Estate
- 422 Tax Deductions for Businesses and Self-Employed Individuals : You Get a Raise Every Time You Find a Legitimate Tax Deduction
- Keys to Reading an Annual Report (Barron's Business Keys)
No comments have been submitted.

