PC Review


Reply
Thread Tools Rate Thread

commandbars.add problem

 
 
=?Utf-8?B?QmlsbHkgQg==?=
Guest
Posts: n/a
 
      5th Oct 2007
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmlsbHkgQg==?=
Guest
Posts: n/a
 
      5th Oct 2007
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:=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
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
CommandBars problem swje Microsoft Word Document Management 0 8th Apr 2008 09:53 AM
commandbars and reference problem =?Utf-8?B?ZGJiMTk3MEBob3RtYWlsLmNvbQ==?= Microsoft Access VBA Modules 0 19th Mar 2007 09:40 PM
CommandBars.Add problem =?Utf-8?B?QmlsbHkgQg==?= Microsoft Excel Programming 2 30th Sep 2006 08:53 AM
VBA problem with CommandBars zuEgg Microsoft Excel Programming 5 28th Jul 2006 04:47 PM
Problem with Inspector CommandBars and MS Word =?Utf-8?B?WXVyaSBMb2Jhbg==?= Microsoft Outlook Program Addins 4 12th Jul 2006 06:26 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:04 PM.