Disabling Q

Hap

Well-known Member
Joined
Jul 20, 2005
Messages
647
What is the command for disabling particular toolbars, buttons, or menu options?

Thanks for any help.
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Private Sub App_WorkbookActivate(ByVal Wb As Workbook)
'ThisWorkbook code!

'Add your Workbook's name here, the one that gets Grayed-out!
If Wb.Name <> "GrayOutToolsCommandBars" Then
'Un-Hide the Print Menu Item!

'File menu, count each item including mouse-over additional items!
Application.CommandBars("File").Controls(15).Enabled = True

'Toolbars: View - Toolbars - Standard
'The actual count from left to right on your tool bar, not a default Index!
Application.CommandBars("Standard").Controls(9).Enabled = True

Else

'Gray-out Hide the Print Menu Item!

'File menu, count each item including mouse-over additional items!
Application.CommandBars("File").Controls(15).Enabled = False

'Toolbars: View - Toolbars - Standard
'The actual count from left to right on your tool bar, not a default Index!
Application.CommandBars("Standard").Controls(9).Enabled = False
End Sub


Sub myHidePrint()
'Standard module code, like: Module1.
'Gray-out Hide the Print Menu Item!

'File menu, count each item including mouse-over additional items!
Application.CommandBars("File").Controls(15).Enabled = False

'Toolbars: View - Toolbars - Standard
'The actual count from left to right on your tool bar, not a default Index!
Application.CommandBars("Standard").Controls(9).Enabled = False
End Sub


Sub myShowPrint()
'Standard module code, like: Module1.
'Un-Hide the Print Menu Item!

'File menu, count each item including mouse-over additional items!
Application.CommandBars("File").Controls(15).Enabled = True

'Toolbars: View - Toolbars - Standard
'The actual count from left to right on your tool bar, not a default Index!
Application.CommandBars("Standard").Controls(9).Enabled = True
End Sub


Sub myHideMB()
'Standard module code, like: Module1.
'Gray-out Hide the Protection Menu Item!

CommandBars("Worksheet Menu Bar").Controls( _
"Tools").Controls("Protection").Enabled = False
End Sub


Sub myShowMB()
'Standard module code, like: Module1.
'Un-Hide the Protection Menu Item!

CommandBars("Worksheet Menu Bar").Controls( _
"Tools").Controls("Protection").Enabled = True
End Sub


Sub myProTest()
'Standard module code, like: Module1.
'Test for protection!

If ActiveSheet.ProtectContents = True Then
MsgBox "Protected!"
Else
MsgBox "Not protected!"
End If
End Sub


Sub myDePro()
'Standard module code, like: Module1.
'Work with the Protection Toolbar!

For Each Bar In Application.CommandBars
If Bar.Name = "Protection" Then
Bar.Protection = msoBarNoProtection
Bar.Enabled = True
Bar.Visible = True
Bar.Position = msoBarSide

MsgBox "Will now Hide the Protection Toolbar!"
Bar.Enabled = False
Bar.Visible = False
End If
Next Bar
End Sub


Sub myBar()
'Standard module code, like: Module1.
'List all toolbars!

For Each Bar In Application.CommandBars
myLst = myLst & Bar.Name & ", "
Next Bar
MsgBox myLst
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,010
Messages
5,569,602
Members
412,282
Latest member
bobHenk
Top