Referencing an "icon"

jerH

Board Regular
Joined
Dec 3, 2008
Messages
168
On the INSERT menu of the Excel ribbon, right under "shapes" you can insert an "icon". Once you've done that, how can you reference the resulting picture via VBA? I tried searching but most of what comes up for "icons" is in relation to conditional formatting....

Thanks!
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,952
Office Version
365, 2010
Platform
Windows
I assume you mean you're just inserting one of the shapes. In this example, I used the Left Right Arrow. In the name box above the spreadsheet, make a note of what it's called. You can copy the name right out of that box.

Code:
Sub test()
ActiveSheet.Shapes("Left-Right Arrow 2").Delete
End Sub
 
Last edited:

jerH

Board Regular
Joined
Dec 3, 2008
Messages
168
Sort of. In Excel 2019 Professional, on the Insert tab under "shapes" there is also "icons". (see attached screenshot) There is a much richer set of shapes to add here. You're right that they are still referenced via the Shapes collection....so if I go to Excel and insert one, it gets a name like "Graphic 2" and I can do
ActiveSheet.Shapes("Graphic 2").delete
and that deletes it....in that sense you have answered my original poorly formed question. Thanks :)

But building on that, I now need to be able to insert one of these programatically. If I look at the object model for the shapes object though, I can find the .addShape method (reference) but it wants the type to be a member of the MsoAutoShapeType enumeration. And that is just the stuff you see under the "shapes" button, not the "icon" button. For instance, under the icon button the first section that shows up is "Accessibility" and it has wheelchair icons, an ear with a line through it for deafness, a braille icon, etc. Do you have any idea how those might be accessed?

Thanks!

Capture.JPG
 

Watch MrExcel Video

Forum statistics

Threads
1,099,362
Messages
5,468,174
Members
406,569
Latest member
Quest_

This Week's Hot Topics

Top