Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded Excel Problem with Menus/Commandbars/Toolbars etc Ashish Excel Programming 0 July 6th 07 02:54 PM
CommandBars.Add problem Billy B Excel Programming 2 September 30th 06 08:53 AM
VBA problem with CommandBars zuEgg Excel Programming 5 July 28th 06 04:47 PM
Commandbars dynamic menu creation problem GusEvans Excel Programming 6 April 6th 06 07:21 PM
CommandBars vs CommandBars(1).Controls Sean Excel Programming 3 April 3rd 06 01:34 PM


All times are GMT +1. The time now is 06:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"