[RESOLVED] How to select the picture/image object in Excel worksheet
Hi, I have this excel worksheet with multiple pictures.
I need to find a way to select each pictures programmatically and do things to it (resizing, move, etc.).
How can I select the picture programmatically without knowing the picture/image name/ID?
PS: the pictures are already in the worksheet, not inserted by my macro.
Re: How to select the picture/image object in Excel worksheet
Record a macro of you doing your actions and then stop and chheck out the generated module code.
Re: How to select the picture/image object in Excel worksheet
Quote:
Originally Posted by RobDog888
Record a macro of you doing your actions and then stop and chheck out the generated module code.
I've done that before posting the question, hence the question.
It selects the picture by referring it to the name
Code:
ActiveSheet.Shapes("_ctl0_reportlist__ctl0_Image3").Select
...
...
ActiveSheet.Shapes("_ctl0_reportlist__ctl1_Image3").Select
...
...
ActiveSheet.Shapes("_ctl0_reportlist__ctl2_Image3").Select
...
...
I can see the ctl0 -> ctl1 -> ctl2 incremented, but the rest doesn't necessarily always like that (depending on what generated the excel file in the first place) - so I can't select the image without first knowing the name.
Re: How to select the picture/image object in Excel worksheet
You can iterate through the Shapes collection using a For Each loop.
Re: How to select the picture/image object in Excel worksheet
Quote:
Originally Posted by RobDog888
You can iterate through the Shapes collection using a For Each loop.
Thanks!!! I didn't remember to use For Each loop, as I hardly use it.