Caption Not Showing

W

Wheat

I created a custom toolbar and add a button to call a
function. The toolbar was created and the button works
fine. The only problem is I can't get the caption to show
on the button. The code is below:

Public Sub CreateQCToolbar()

Dim bars As CommandBars
Dim bar As CommandBar
Dim barcontrols As CommandBarControls
Dim barcontrol As CommandBarControl
Dim button As CommandBarButton

Set bars = Excel.CommandBars

For Each bar In bars
If bar.Name = "A&E QC" Then
bar.Delete
End If
Next

bars.Add "A&E QC", msoBarTop, False, False

Set bar = bars("A&E QC")
bar.Visible = True

Set bars = Nothing
Set barcontrols = bar.Controls
Set bar = Nothing

barcontrols.Add msoControlButton, 1, , , False

Set barcontrol = barcontrols(1)
With barcontrol
.Caption = "Refresh QC Sheet"
.Enabled = True
.OnAction = "Refresh"
.Visible = True
End With

Set button = barcontrol
With button
.FaceId = 39
End With

Set barcontrols = Nothing
Set barcontrol = Nothing
Set button = Nothing

End Sub

Currently, only the FaceID (-->) is showing. Any ideas
why the caption won't show? Thanks!
 
W

Wheat

I got the the caption to show by adding the following line
to the first "With" statement:

..Style = msoButtonIconAndCaption
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top