When a picture is inserted into an Excel worksheet using Shapes.AddPicture(...) method, Excel gives it a name "Picture 1", "Picture 2" etc automatically.
This name can be used to get a reference to this shape object in Shapes collection like Shapes.Item("Picture 1"). If the name is changed in Excel using the Name Box, there are two different names (or one of them is a key/Caption) through which the Shape object can be referenced. So if I change the name to "MyPic" I can use any of these to reference a shape in Shapes collection:
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?
UPDATED
What I am trying to do is to link a cell to a picture in Excel. I keep the picture data in cell's comment. These are the scenarios:
- If I keep the picture name (external name) then copy-pasting the structure on the same worksheet will duplicate the name and the cell will point to the same structure.
- If I keep the internal name then copy-pasting to other worksheet will create problem as the same internal name can exist on some other worksheet in the same workbook.
- If I take ID, I will not be able to get the Picture reference from it
For me getting the internal name is important. I have the Shape reference but no idea how to get the internal name from this ref.