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.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,111
Messages
5,835,444
Members
430,356
Latest member
RadStorm20

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top