I placed in this code in ThisWorkbook in an attempt to have it remove all Toolbars and Menus from Sheet2 only, but it's triggering the Macro Name prompt. How do I fix that. It's just supposed to run automatically without a Macro. There is also a bit of code above that to allow the Macro buttons on the other sheets to work when the worksheet is protected. The bit I need sorted out is the one that starts with - Private Sub Workbook_SheetActivate(ByVal Sh As Object)
I should also point out that Sheet2 is named COVER. Should I be referring to Sheet2 or COVER in the code?
Many thanks in advance for your help!
I should also point out that Sheet2 is named COVER. Should I be referring to Sheet2 or COVER in the code?
VBA Code:
Private Sub Workbook_Open()
Call AllowMacroWhenProtected
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim ws As Worksheet
If ActiveSheet.Name = "Sheet2" Then
Application.CommandBars("Worksheet Menu Bar").Enabled = False
Application.CommandBars("Standard").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Custom 1").Visible = False
With ActiveWindow
.DisplayHorizontalScrollBar = False
.DisplayVerticalScrollBar = False
End With
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = False
Else
Application.CommandBars("Worksheet Menu Bar").Enabled = True
Application.CommandBars("Standard").Visible = True
Application.CommandBars("Formatting").Visible = True
Application.CommandBars("Custom 1").Visible = True
With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
End With
Application.DisplayFormulaBar = True
Application.DisplayStatusBar = True
End If
Application.DisplayAlerts = True
End Sub
Many thanks in advance for your help!