Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Icons In User Added Sub-Menus

Status
Not open for further replies.

snikde

Programmer
Mar 13, 2002
35
US
I have been adding custom menus and submenus with calls like:

MenuBars(xlWorksheet).Menus("Data Management").MenuItems.Add Caption:="Get 4D Costs", OnAction:="GetCosts"

I noticed that to the left of the submenu (the gray area) many of Excel's default menus have icons (like the File menu, Save, etc.) Can I add via VBA icons of my own or Excel icons to these submenus? Code sample would be helpful

TIA

Guy
 
Sure. Right click the toolbar with the menu, select Customize. Find your menu item, and right click that. You can Change button imagem, or even edit it. Any .ico file can be used. You can even take a tiny tiny .jpg and rename it .ico, copy it to the clipboard, then paste it in. Voila - your menu icon.

Gerry
 
Hi Guy
Just to add a little to what Gerry has said you can add the icons at run time. This is definately true for the built in ones but I'm not sure about doing it with your own.

Below is an example to add the 'calculator' icon to your toolbar. I've also 'modified' your code a little! If you check the FAQ section there is some code (one of mine!) which will list the builtin faces for buttons in Word & Excel. I'm not sure at the moment how to pull up the 'custom' faces.

I've also heard of a addin or something similar that sows all the available faceIDs but I can't remember where it is.
(If anyone else knows, I'd like to find it again????)

You may also want to look into the copyface & pasteface methods.

Good luck!

Code:
Dim cbc As CommandBarControl
Set cbc = CommandBars("Worksheet Menu Bar").Controls("Data Management").Controls.Add
    With cbc
        .Caption = "Get 4D Costs"
        .OnAction = "GetCosts"
        .FaceId = 283   'calculator
    End With

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Hi Loomah. Not quite understanding your comment. What are you not sure of??

You state you can do it with built-in icons, but not sure with noncuiltin icons. Arumph, there is a Paste menu item. You can use Paint if you want, just make an icon sized bitmap image and copy it from some app (into the Clipboard, right) and thren in Word while you doing the customize thing, use Paste. As stated, you can use ANY bitmap format, resize it, call it an .ico file and it will work as well.

So...what is that you think may not work?

Gerry
 
Hi Gerry
My comment - "I'm not sure about doing it with your own" - has nothing to do with whether it is possible to do but is more the fact that I don't know how to do it with code!! I'd guess at using the pasteface method, but I haven't sat and worked it out.

Nothing more sinister than me pointing at something (else) I don't know!

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Oh, sorry, I did not mean to sound grumpy...my apologies...I just reread, and, uh...I sound grumpy. Yikes.

I also...[blush] missed that snikde was trying to do this with code.

Sorry for the grumpiness Loomah.



Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top