Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
commandbars.add problem
I found that I had not deleted the toolbar on close so. Thanks.
"Billy B" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Embedded Excel Problem with Menus/Commandbars/Toolbars etc | Excel Programming | |||
CommandBars.Add problem | Excel Programming | |||
VBA problem with CommandBars | Excel Programming | |||
Commandbars dynamic menu creation problem | Excel Programming | |||
CommandBars vs CommandBars(1).Controls | Excel Programming |