PC Review


Reply
Thread Tools Rate Thread

caption property in command bar (excel 2003)

 
 
=?Utf-8?B?amlsbGM=?=
Guest
Posts: n/a
 
      30th Aug 2007
I am trying to add a caption to a control button on a command bar using many
variations of the following code in the Workbook_Open event:
Set myBar = Application.CommandBars.Add(myName, msoBarTop, , True)
With myBar
.Controls.Add msoControlButton
.Controls(1).Caption = "useful info"
End With

The command bar shows no button, just blank space, if the mouse hovers over
the space the caption appears, but I want the caption to appear on a button
that a user can press. I can attach the correct macro to the 'space' and
works if i click the 'space'.

Where am I going wrong?
--
Thanks in advance, Jill C
 
Reply With Quote
 
 
 
 
papou
Guest
Posts: n/a
 
      30th Aug 2007
Hello Jill
Set myBar = Application.CommandBars.Add(myName, msoBarTop, , True)
set Myctr = myBar.Controls.Add msoControlButton
Myctr.Caption = "useful info"

HTH
Cordially
Pascal

"jillc" <(E-Mail Removed)> a écrit dans le message de news:
9B7AF605-BCD3-402E-B0E2-(E-Mail Removed)...
>I am trying to add a caption to a control button on a command bar using
>many
> variations of the following code in the Workbook_Open event:
> Set myBar = Application.CommandBars.Add(myName, msoBarTop, , True)
> With myBar
> .Controls.Add msoControlButton
> .Controls(1).Caption = "useful info"
> End With
>
> The command bar shows no button, just blank space, if the mouse hovers
> over
> the space the caption appears, but I want the caption to appear on a
> button
> that a user can press. I can attach the correct macro to the 'space' and
> works if i click the 'space'.
>
> Where am I going wrong?
> --
> Thanks in advance, Jill C



 
Reply With Quote
 
=?Utf-8?B?SGFsaW0=?=
Guest
Posts: n/a
 
      30th Aug 2007
hi,

I've modify your code:
Dim mybar As CommandBar, Myname
Dim btn As CommandBarButton

Myname = "Test"
Set mybar = Application.CommandBars.Add(Myname, msoBarTop, , True)
Set btn = mybar.Controls.Add(msoControlButton)
With btn
.Caption = "useful info"
.Style = msoButtonCaption
End With
mybar.Visible = True

<smile>
--
Regards,

Halim



"jillc" wrote:

> I am trying to add a caption to a control button on a command bar using many
> variations of the following code in the Workbook_Open event:
> Set myBar = Application.CommandBars.Add(myName, msoBarTop, , True)
> With myBar
> .Controls.Add msoControlButton
> .Controls(1).Caption = "useful info"
> End With
>
> The command bar shows no button, just blank space, if the mouse hovers over
> the space the caption appears, but I want the caption to appear on a button
> that a user can press. I can attach the correct macro to the 'space' and
> works if i click the 'space'.
>
> Where am I going wrong?
> --
> Thanks in advance, Jill C

 
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
Caption Property the dude Microsoft Excel Misc 1 1st Jun 2006 10:23 AM
Caption property the dude Microsoft Excel Programming 1 1st Jun 2006 10:06 AM
Caption Property =?Utf-8?B?dHVybmVy?= Microsoft Access Form Coding 2 6th Jul 2005 05:27 AM
Caption property =?Utf-8?B?a2Vu?= Microsoft Access Reports 1 22nd Jun 2005 03:31 PM
Caption property =?Utf-8?B?a2Vu?= Microsoft Access Database Table Design 1 22nd Jun 2005 01:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:52 PM.