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
• 38,010 points
1,217 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
• 63,420 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
• 63,420 points
1,227 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
• 63,420 points
2,129 views
0 votes
1 answer

How to automatically get a specified range of data from Excel to XML in VBA

Range method works, always identify the sheet ...READ MORE

answered Mar 18, 2023 in Others by narikkadan
• 63,420 points
545 views
0 votes
1 answer

How to programmatically get the values of a spilled Excel range in VBA?

By using the Text property, I was ...READ MORE

answered Mar 23, 2023 in Others by narikkadan
• 63,420 points
728 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
916 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
3,240 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
• 23,260 points
532 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,670 points
769 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
• 63,420 points
380 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
• 63,420 points
461 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