Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default caption property in command bar (excel 2003)

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 182
Default caption property in command bar (excel 2003)

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
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
Carriage Retunr in the Caption property of a CommandButton control Jean-Pierre Bidon Excel Programming 1 July 20th 07 02:56 PM
Caption Property the dude Excel Discussion (Misc queries) 1 June 1st 06 10:23 AM
Caption property the dude[_4_] Excel Programming 1 June 1st 06 10:06 AM
Command Button Caption Qaspec Excel Programming 1 January 27th 05 03:30 PM
why doesn't this caption property work Brian Excel Programming 1 December 29th 04 08:45 PM


All times are GMT +1. The time now is 09:35 AM.

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

About Us

"It's about Microsoft Excel"