B
Billy B
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:=msoControlButton)
Set NewBtn2 = CommandBars("Call").Controls.Add(Type:=msoControlButton)
Set newbtn3 = CommandBars("Call").Controls.Add(Type:=msoControlButton)
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
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:=msoControlButton)
Set NewBtn2 = CommandBars("Call").Controls.Add(Type:=msoControlButton)
Set newbtn3 = CommandBars("Call").Controls.Add(Type:=msoControlButton)
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