View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Billy B Billy B is offline
external usenet poster
 
Posts: 54
Default CommandBars.Add problem

I am trying to create a toolbar with a button on it in the Workbook.Activate
event. Below is the code so far. I error out at the With TBar .Name line so I
don't know if anything else is wrong. Help would be greately appreciated.

Sub MakeToolbarBtn()
'
' Create new toolbar and button
Dim TBar As CommandBar
Dim NewBtn As CommandBarButton

Set TBar = CommandBars.Add
With TBar
.Name = "WWEnviro"
.Top = 0
.Left = 0
.Visible = True
End With

Set NewBtn = CommandBars("WWEnviro").Controls.Add _
(Type:=msoControlButton)
With NewBtn
.FaceId = 300
.OnAction = "FixIt"
.Caption = "FixFormatting"
End With
On Error Resume Next
'On Error GoTo 0

End Sub

Thank you