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 have the following code to create a toolbar on the fly in an Excel 2002
workbook. When I try to run it I get a Runtime error '5' Invalid procedure
call or argument. I have compared my code with the text I have and can't find
anything wrong. Thank you.

Public Sub CreateTheToolbar()
Dim TBar As CommandBar
'************ next line errors out
Set TBar = CommandBars.Add(Name:="Call")
With TBar
.Position = msoBarBottom
.Visible = True
End With

AddButton
End Sub
Private Sub AddButton()
Set NewBtn1 = CommandBars("Call").Controls.Add(Type:=msoControlB utton)
Set NewBtn2 = CommandBars("Call").Controls.Add(Type:=msoControlB utton)
Set newbtn3 = CommandBars("Call").Controls.Add(Type:=msoControlB utton)

With NewBtn1
.FaceId = 41
.OnAction = "HideInstructor"
.Caption = "Hide Instructors"
End With

With NewBtn2
.FaceId = 39
.OnAction = "Show Instructors"
.Caption = "Show Instructors"
End With

With newbtn3
.FaceId = 31
.OnAction = "PrintIt"
.Caption = "Print Callout"
End With


End Sub