Actually I'm correcting my own post above.
With the custom commandbar I can change the faceID displayed of the buttons
on the top level of the commandbar, but not those on popup menus on the
commandbar, even tho I can change the recorded value of the faceID for all
buttons.
Any ideas on how to make the change display?
Thanks
You need to set the .Style property of the control to a type that allows an
icon. For some reason, this does not seem to be covered very well in the VBA
help.
The code below adds a control to the end of the File menu, sets the caption
to "Test", sets the style to msoButtonIconAndCaption and adds the icon
identified by FaceId 1087:
Dim oControl As CommandBarControl
Set oControl =
CommandBars.ActiveMenuBar.Controls("File").Controls.Add(Type:=msoControlButton)
With oControl
.Caption = "Test"
.Style = msoButtonIconAndCaption
.FaceId = 1087
End With
Set oControl = Nothing
MsoButtonIconAndCaption is a member of msoButtonStyle. You can look up the
members in the Object Browser (F2).

Signature
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
> Actually I'm correcting my own post above.
> With the custom commandbar I can change the faceID displayed of the buttons
[quoted text clipped - 5 lines]
>
> Thanks
MikeB77 - 03 Nov 2007 10:51 GMT
HI Lene
Thanks for having a look. yes I've set the button .style
=MsoButtonIconAndCaption when i created the control, and can see the image
originally assigned to the control.
Problem is I can't change the displayed image unless I can actually see it
(I don't mean .visible). I.e it has to be displayed on a commandbar to
change. It won't change if on a popup on the same bar, nor a menu bar popup
etc.
At the risk of being very boring, here's some code that shows the problem.
it can change the "Button1" image, but not for "Button2":
Sub aChangeFace() 'change the faceID shown
x = "Button1"
If MsgBox("button 1 (y) or 2(n)", vbYesNo, "change faceID") = vbNo Then
x = "Button2"
With Application.CommandBars.FindControl(Tag:=x)
waz = .FaceId
If .FaceId = 1088 Then
.FaceId = 1087
Else
.FaceId = 1088
End If
MsgBox "now= " & .FaceId, , .Caption & " faceID was " & waz
End With
End Sub
Sub aMakeMyBar()
Dim myMenu As CommandBar
Dim btn As CommandBarButton
Dim subMenu As CommandBarPopup
On Error Resume Next
Application.CommandBars("MyBar").Delete
On Error GoTo 0
Set myMenu = Application.CommandBars.Add("MyBar", msoBarTop, , True)
myMenu.Visible = True
With myMenu.Controls
Set btn = .Add(Type:=msoControlButton)
With btn
.Style = msoButtonIconAndCaption
.FaceId = 123
.Caption = "Button1"
.Tag = "Button1"
.OnAction = "ButtonAction1"
End With
Set subMenu = .Add(Type:=msoControlPopup)
With subMenu
.Caption = "subMenu"
.Tag = "subMenu"
Set btn = .Controls.Add(Type:=msoControlButton)
With btn
.Style = msoButtonIconAndCaption
.FaceId = 123
.Caption = "Button2"
.Tag = "Button2"
.OnAction = "ButtonAction2"
End With
End With
End With
End Sub
Sub ButtonAction1()
MsgBox "Button 1 Click."
End Sub
Sub ButtonAction2()
MsgBox "Button 2 Click."
End Sub
Lene Fredborg - 03 Nov 2007 12:39 GMT
As far as I can see, the problem has nothing to do with whether you can see
the control or not. If you insert an "End If" after the line:
x = "Button2"
in the procedure "aChangeFace", it works (at least in my test).
You should also set the CustomizationContext whenever you change CommandBars
in order to make sure in which context the changes are made.

Signature
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
> HI Lene
> Thanks for having a look. yes I've set the button .style
[quoted text clipped - 65 lines]
> End Sub
>