View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kevin G Kevin G is offline
external usenet poster
 
Posts: 9
Default hiding Worksheet menu bar

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

-----Original Message-----
Hi,


Is it possible to hide the Worksheet menu bar?

What I'm trying is the following:
CommandBars(1).Visible = False

This gives me an error:
Error -2147467259(80004005) during execution:
Method Visible of CommandBas has failed


Many thanks in advance,

Yves


.