View Single Post
  #1   Report Post  
Anthony
 
Posts: n/a
Default VBA script help..Please !!!!

I have been given the script below by Ron De Bruin - and I can't thank him
enough, however I'm still scratching my head as it doesn't EXACTLY what I
want.

I want ALL the built in command bars/toolbars etc that are shown in a normal
excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal
toolbar named 'LOG' and the 'Worksheet Menu Bar'.

2 problems arise from the script below :-

1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not.
2) If I open another seperate excel sheet, all the same commands have been
copied to this new excel workbook, whereas I want all the normal toolbars etc
showing.

here's the script :-

Private Sub workbook_Beforeclose(Cancle As Boolean)
On Error Resume Next 'in case toolbar is absent
Application.CommandBars("log").Delete

End Sub


Private Sub Workbook_Activate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
If Cbar.Name < "Worksheet Menu Bar" And Cbar.Name < "log" Then
Cbar.Enabled = True
End If
Next
With Application
.DisplayFormulaBar = False
.DisplayStatusBar = False

End With
End Sub

Private Sub Workbook_Deactivate()
Dim Cbar As CommandBar
For Each Cbar In Application.CommandBars
Cbar.Enabled = True
Next
With Application
.DisplayFormulaBar = True
.DisplayStatusBar = True
End With
End Sub

Can anybody help with this....pls pls pls !!!!!!!!!!!