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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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
Back
Top