PDA

View Full Version : [SOLVED:] Adding Icons to Add-in



Djblois
03-03-2007, 06:27 PM
I want to start adding icons to my add-in. However, where can I find a list of what is the index number for icons?

Bob Phillips
03-04-2007, 03:31 AM
Courtesy of John Walkenbach



Sub ShowFaceIDs()
Dim oToolbar As CommandBar
Dim oButton As CommandBarButton
Dim i As Long, IDStart As Long, IDStop As Long
On Error Resume Next
Application.CommandBars("FaceIds").Delete
On Error GoTo 0
Set oToolbar = Application.CommandBars.Add _
(Name:="FaceIds", temporary:=True)
oToolbar.Visible = True
IDStart = 1 '<=== change to 500 to get next 500 etc.
IDStop = IDStart + 499
For i = IDStart To IDStop
Set oButton = oToolbar.Controls.Add _
(Type:=msoControlButton, ID:=2950)
oButton.FaceId = i
oButton.Caption = "FaceID = " & i
Next i
oToolbar.Width = 600
End Sub


Just hover over the button to get its id.

Djblois
03-16-2007, 05:35 AM
Is it possible to add icons to the dropdowns I have created on my toolbar? I found how to add them to buttons but what about the dropdowns?

tpoynton
03-16-2007, 07:45 AM
the faceid property applies to menu items as well. Use the same as you do the caption and onaction properties of the menu items.

Djblois
03-16-2007, 08:26 AM
I tried that and it gave me a compile error:


Set menuObject = Tbar.Controls.Add(Type:=msoControlPopup)
menuObject.Caption = "Reports"
menuObject.faceid = "139"

tpoynton
03-16-2007, 10:13 AM
try


Set menuObject = Tbar.Controls.Add(Type:=msoControlPopup)
with menuObject
.Caption = "Reports"
.faceid = 139
end with
it might work without the with statement; try removing the quotes around the 139

vonpookie
03-16-2007, 11:12 AM
John Walkenbach also has an add-in available that will show you the image as well as what faceID goes with it:
http://j-walk.com/ss/excel/tips/tip67.htm

Bob Phillips
03-16-2007, 01:25 PM
You cannot add a faceid to a popup, just a button.

tpoynton
03-16-2007, 01:43 PM
Thanks Bob; that helps me! I did not catch it was 'msoControlPopup'...but even if I did, I would have probably still made the same mistake.

Djblois
03-16-2007, 06:27 PM
Thank you all for you help I didn't think it was possible but I was hoping. You are all great help.

TrippyTom
03-19-2007, 10:00 AM
Hey guys,

I wanted to add another question to this since it relates:
Can someone please explain how to use the copyface feature (not sure of the actual name) to define my own images on buttons for my toolbar? I have added a lot of macros for my coworkers and it's getting to the point where I need to make it it's own add-in, but the default icons that come with Excel don't really fit my needs.

I can't remember the name of the function.

Bob Phillips
03-19-2007, 09:07 PM
TT
cbTable.Shapes(shapename).CopyPicture
cbCtl.PasteFace where cbTable is the codename of the sheet containing the picture, shapename is the name of the shape, such as 'Picture 30', and cbCtl is an object variable for the control being added.

Bob Phillips
03-19-2007, 09:08 PM
Admin type person help me please!

mdmackillop
03-20-2007, 01:31 AM
Hi Bob,
Your code display looks OK to me.

Bob Phillips
03-20-2007, 11:57 AM
Weird, it looked odd when posted.

TrippyTom
03-20-2007, 02:22 PM
Thanks XLD :)

I actually have to do it in PPT, but I'm sure it's a similar process. So if I understand this correctly, I have to name each picture so I can reference it in the code to paste it via the clipboard.

TrippyTom
03-20-2007, 05:21 PM
XLD,
Adapting this to PPT works great if it's a regular powerpoint file, but when I save it as an add-in, it can't see the first slide, so it can't see the objects either, so my toolbar ends up looking like this.

Note: the one that shows up is using a regular reference to the .faceid

Is there a workaround?

TrippyTom
03-21-2007, 09:43 AM
I am assuming I would have to save the images in their own file, copy directly from file to clipboard, then from clipboard to toolbar?

Does anyone have an example of how I could do that?

TrippyTom
03-21-2007, 11:21 AM
I found the solution here:
http://pptfaq.com/FAQ00495.htm