Accessing Inserted Image in Excel VBA Module
I'm new to the VB world and I am currently copying + pasting parts of my tribe sheet like this:
Sheets("Overview").Range("G4:P34").CopyPicture
Sheets("Overview").Paste Destination:=Worksheets("Overview").Range("T4")
So basically I just copy the area from G4 to P34 as an image and paste it starting at T4 which works fine far. The thing is, the newly created image gets an auto-assigned attribute Name
, so I can't access it as easily as the following snippet, because I really don't know its name:
Sheets("Overview").Shapes("Picture xx").DoSomethingWithIt
My question is, how can I access the picture I just put in my sheet? Any advice would be appreciated, thanks a lot in advance.
source to share
I think what you want is the Application.Caller property that returns what was called. Example:
sub pic()
ActiveSheet.Shapes(Application.Caller).Select
'some code
End Sub
This should select the last object (picture) without remembering its name. You can find out about it here
http://msdn.microsoft.com/en-us/library/office/ff193687(v=office.15).aspx
source to share