View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Hiding all Toolbars

Jonathan,

You should check out the previous posts, I have already answered (a very
similar question) today. Here is that code, modified for your needs

Here is some code to hide them and restore them. This code would go in the
ThisWorkbook code module. Your code to create the special CBs should be run
before you hide the others.

Dim aryCBs

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim i As Long

For i = LBound(aryCBs) To UBound(aryCBs)
If oCB.Name = "Worksheet Menu Bar" Then
Application.CommandBars(aryCBs(i)).Enabled = True
Else
Application.CommandBars(aryCBs(i)).Visible = True
End If
Next i

End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
Dim i As Long

ReDim aryCBs(0)
For Each oCB In Application.CommandBars
If oCB.Visible Then
If oCB.Name = "Worksheet Menu Bar" Then
oCb.Enabled = False
Else
oCB.Visible = False
End If
ReDim Preserve aryCBs(i)
aryCBs(i) = oCB.Name
i = i + 1
End If
Next oCB

End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jonathan" wrote in message
...
Hi All,

I'm hoping somebody could furnish me with / point me to some VB script in

order to hide all the toolbars (including the File Menu) in Excel when I
open a particular workbook, but that doesn't leave Excel without toolbars
upon exit of that workbook.

Many thanks in anticipation,

Jonathan