K
Kevin G
this was taken from www.tek-tips.com:
Sub DisableMenu_HideControlBars()
Dim comBar As CommandBar
Dim comCtrl As CommandBarControl
Dim comBtn As CommandBarButton
'This will hide all of the Command bars that are visible
(open)
For Each comBar In CommandBars
If comBar.BuiltIn And comBar.Visible = True Then
comBar.Enabled = False
For Each comCtrl In comBar.Controls
If comCtrl.BuiltIn And comBar.Visible = True Then
comCtrl.Enabled = False
End If
Next comCtrl
End If
Next comBar
' The following will hide/disable the File & Edit items in
Excel's Menu Bar
With CommandBars("Worksheet Menu Bar")
.Enabled = True
With .Controls("File")
.Enabled = False
.Visible = False
End With
With .Controls("Edit")
.Enabled = False
.Visible = False
End With
End Sub
Sub EnableMenu_UnhideControlBars()
Dim comBar As CommandBar
Dim comCtrl As CommandBarControl
Dim comBtn As CommandBarButton
For Each comBar In CommandBars
'This will unhide all of the Command bars that were
visible (open)
If comBar.BuiltIn And comBar.Enabled = False Then
comBar.Visible = True
comBar.Enabled = True
For Each comCtrl In comBar.Controls
If comCtrl.BuiltIn And comBar.Enabled = False
Then
comCtrl.Visible = True
comCtrl.Enabled = True
End If
Next comCtrl
End If
Next comBar
' The following will unhide/enable the File & Edit items
in Excel's Menu Bar
With CommandBars("Worksheet Menu Bar")
.Enabled = True
With .Controls("File")
.Enabled = True
.Visible = True
End With
With .Controls("Edit")
.Enabled = True
.Visible = True
End With
End Sub
Sub DisableMenu_HideControlBars()
Dim comBar As CommandBar
Dim comCtrl As CommandBarControl
Dim comBtn As CommandBarButton
'This will hide all of the Command bars that are visible
(open)
For Each comBar In CommandBars
If comBar.BuiltIn And comBar.Visible = True Then
comBar.Enabled = False
For Each comCtrl In comBar.Controls
If comCtrl.BuiltIn And comBar.Visible = True Then
comCtrl.Enabled = False
End If
Next comCtrl
End If
Next comBar
' The following will hide/disable the File & Edit items in
Excel's Menu Bar
With CommandBars("Worksheet Menu Bar")
.Enabled = True
With .Controls("File")
.Enabled = False
.Visible = False
End With
With .Controls("Edit")
.Enabled = False
.Visible = False
End With
End Sub
Sub EnableMenu_UnhideControlBars()
Dim comBar As CommandBar
Dim comCtrl As CommandBarControl
Dim comBtn As CommandBarButton
For Each comBar In CommandBars
'This will unhide all of the Command bars that were
visible (open)
If comBar.BuiltIn And comBar.Enabled = False Then
comBar.Visible = True
comBar.Enabled = True
For Each comCtrl In comBar.Controls
If comCtrl.BuiltIn And comBar.Enabled = False
Then
comCtrl.Visible = True
comCtrl.Enabled = True
End If
Next comCtrl
End If
Next comBar
' The following will unhide/enable the File & Edit items
in Excel's Menu Bar
With CommandBars("Worksheet Menu Bar")
.Enabled = True
With .Controls("File")
.Enabled = True
.Visible = True
End With
With .Controls("Edit")
.Enabled = True
.Visible = True
End With
End Sub