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!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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:
Upvote 0
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
 
Upvote 0
This question is very old but I thought I might add something that helped me locate the names of the icons in my sheet to reference them in VBA, as well as rename them, for future visitors.

To find the names of icons you've used on your sheet follow these steps:
  1. Click on the icon you've inserted into your Excel worksheet to select it.
  2. Review the Name in the Selection Pane:
    • Go to the "Home" tab on the Excel ribbon.
    • In the "Editing" group, click on "Find & Select."
    • Click on "Selection Pane."
    • The Selection Pane will appear on the right side of your worksheet. It will list all the objects on your sheet with their names.
    • To change the pre-determined icon names, double click on the icon name in the selection pane and replace with desired name.
  3. To reference icon in VBA use this code: ActiveSheet.Shapes.Range(Array("ICONNAME")).Select
Hope this helps someone! Cheers
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,749
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top