Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Command Bars

I have written myself a macro which designs a command bar. Unfortunately I
can't work out how to tell it to show text as well as icons. Any ideas?

Many Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Command Bars

Hi Neil,

You need to set the individual button's style property to :
msoButtonIconAndCaption

Here is a simple VBA help custom toolbar which I have adapted to give one
button a text display and another a text and icon display:

Sub TestBar()

Dim customBar As CommandBar
Dim newButton As CommandBarButton
Set customBar = CommandBars.Add("Custom2")
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Cut").ID)
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Copy").ID)
newButton.Style = msoButtonIconAndCaption
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Paste").ID)
newButton.Style = msoButtonCaption
customBar.Visible = True

End Sub


---
Regards,
Norman



"Neil Hopkinson" wrote in message
...
I have written myself a macro which designs a command bar. Unfortunately I
can't work out how to tell it to show text as well as icons. Any ideas?

Many Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Command Bars

Excellent, thanks very much

"Norman Jones" wrote:

Hi Neil,

You need to set the individual button's style property to :
msoButtonIconAndCaption

Here is a simple VBA help custom toolbar which I have adapted to give one
button a text display and another a text and icon display:

Sub TestBar()

Dim customBar As CommandBar
Dim newButton As CommandBarButton
Set customBar = CommandBars.Add("Custom2")
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Cut").ID)
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Copy").ID)
newButton.Style = msoButtonIconAndCaption
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Paste").ID)
newButton.Style = msoButtonCaption
customBar.Visible = True

End Sub


---
Regards,
Norman



"Neil Hopkinson" wrote in message
...
I have written myself a macro which designs a command bar. Unfortunately I
can't work out how to tell it to show text as well as icons. Any ideas?

Many Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Command Bars

Hi Neil,

Or better, in case the toolbar exists or the procedure is run multiple
times:

Sub TestBar()

Dim customBar As CommandBar
Dim newButton As CommandBarButton

On Error Resume Next
CommandBars("MyDemoBar").Delete
On Error GoTo 0

Set customBar = CommandBars.Add("MyDemoBar")
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Cut").ID)
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Copy").ID)
newButton.Style = msoButtonIconAndCaption
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Paste").ID)
newButton.Style = msoButtonCaption
customBar.Visible = True

End Sub

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Neil,

You need to set the individual button's style property to :
msoButtonIconAndCaption

Here is a simple VBA help custom toolbar which I have adapted to give one
button a text display and another a text and icon display:

Sub TestBar()

Dim customBar As CommandBar
Dim newButton As CommandBarButton
Set customBar = CommandBars.Add("Custom2")
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Cut").ID)
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Copy").ID)
newButton.Style = msoButtonIconAndCaption
Set newButton = customBar.Controls _
.Add(msoControlButton, CommandBars("Edit") _
.Controls("Paste").ID)
newButton.Style = msoButtonCaption
customBar.Visible = True

End Sub


---
Regards,
Norman



"Neil Hopkinson" wrote in
message ...
I have written myself a macro which designs a command bar. Unfortunately I
can't work out how to tell it to show text as well as icons. Any ideas?

Many Thanks





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
programming command bars Little Elephant with Big Ears Excel Discussion (Misc queries) 3 January 15th 10 07:16 PM
Command Bars KneeDown2Up Excel Discussion (Misc queries) 4 January 16th 07 05:43 PM
Command Bars nath Excel Programming 2 August 23rd 04 01:45 PM
command bars Geo Siggy[_16_] Excel Programming 6 April 22nd 04 10:50 AM
Attaching Command Bars to Add-IN Thomas Herr Excel Programming 3 April 5th 04 08:38 PM


All times are GMT +1. The time now is 10:12 PM.

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"