How to get Shape s internal name in Excel

0 votes

When a picture is added using Shapes to an Excel spreadsheet. When using the AddPicture(...) method, Excel automatically names the image "Picture 1," "Picture 2," etc.

By using this name, you can obtain a reference to this form object from the Shapes collection, such as Shapes. Item ("Picture 1"). There are two separate names (or one of them is a key/Caption) through which the Shape object can be referred if the name is modified in Excel using the Name Box. I can therefore use any of them to refer to a shape in the Shapes collection if I alter the name to "MyPic":

Shapes.Item("Picture 1")
OR
Shapes.Item("MyPic")

The name can be accessed using Shape.Name property in VBA but how can we access the other value (MyPic) that does not seem to change internally?

Nov 12, 2022 in Others by Kithuzzz
• 28,520 points
180 views

1 answer to this question.

0 votes
You can reference a shape by using oSht.Shapes(Osht.Shapes.count) as soon as you add it to a worksheet (oSht). oSht.Shapes, then (osht.shapes.count). Name will reveal its name to you.

If you know a shape's name and want to locate its index in the Shapes collection, you must loop through the Shapes collection.

Until you locate it, name. You can create the "Picture n" alternate name or store the "Picture n" alternate name if you know the Index. By iterating through the Shapes collections until you locate the Shape.ID, you can also store the shape's ID property and later use it as a reference. The external name, alternate name, Shapes index, and ID will all be changed if the user changes the shape to another sheet before renaming it, making it impossible to distinguish it from the original form. Therefore, if this is an issue in your situation, you should think about shadow copying or sheet protection.
answered Nov 12, 2022 by narikkadan
• 52,760 points

Related Questions In Others

0 votes
1 answer

How to merge two cells in excel with same field name

Insert 2 new columns, G & H. Enter ...READ MORE

answered Oct 7, 2022 in Others by narikkadan
• 52,760 points
165 views
0 votes
1 answer

How to get sum of all matches of HLOOKUP in Excel?

Consider: =SUMPRODUCT((A1:E1="apple")*(A2:E2)) To include more ...READ MORE

answered Oct 16, 2022 in Others by narikkadan
• 52,760 points
230 views
0 votes
2 answers

How to get the URL of the current tab in Google Chrome?

Its so simple.... If you want to ...READ MORE

answered Aug 12, 2020 in Others by Steve
• 200 points
1,556 views
0 votes
1 answer

What is a name function in JavaScript & how to define it?

A named function declares a name as ...READ MORE

answered Mar 7, 2019 in Others by Frankie
• 9,830 points
2,250 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
529 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,405 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 22,940 points
117 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,630 points
294 views
0 votes
1 answer

How to get the excel file name / path in VBA

Use FullName, for example: strFileFullName = ThisWorkbook.FullName ...READ MORE

answered Dec 23, 2022 in Others by narikkadan
• 52,760 points
65 views
0 votes
1 answer

How to get rid of a #value error in Excel?

Changing the format to "Number" doesn't actually ...READ MORE

answered Oct 3, 2022 in Others by narikkadan
• 52,760 points
135 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP