Please help need to Close(visible=false) All Command bars except Standard

  • Thread starter Thread starter NetWave128
  • Start date Start date
N

NetWave128

Public Sub HideTools()
Dim MyToolBars As CommandBarControls 'all toolbars
Dim MasterTools As CommandBarControls 'tools needed to use model a
user
On Error GoTo ErrorHandler

Set MasterTools = Application.CommandBars("Standard").Controls

For Each MyToolBar In CommandBarControl 'will loop for eac
commandbarcontrol open
'<> = is when comparing objects or If Not_OBJECT_Is_COLLECTION
If Not MyToolBar Is MasterTools Then
MyToolBar.Visible = False
End If
Next

Set MyToolBars = Nothing
Set MasterTools = Nothing

Exit Sub '<-- if everything runs error-free, you will exit here, BEFOR
the error handler.

ErrorHandler:
MsgBox "Sorry, an error occurred." & vbCrLf & "Number: " & Err.Number
vbCrLf & "Description: " & Err.Description, vbCritical, "Error"

End Su
 
For Each cb In Application.CommandBars
If cb.Caption <> "Standard" Then
If cb.Name <> "Worksheet Manu Bar" Then
cb.Visible = False
Else
cb.Enabled = False
End If
End If
Next cb



--

HTH

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top