|
-
May 3rd, 2006, 08:57 PM
#1
Thread Starter
Member
[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.
-
May 3rd, 2006, 10:09 PM
#2
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 3rd, 2006, 10:25 PM
#3
Thread Starter
Member
Re: How to select the picture/image object in Excel worksheet
 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.
-
May 3rd, 2006, 10:32 PM
#4
Re: How to select the picture/image object in Excel worksheet
You can iterate through the Shapes collection using a For Each loop.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 3rd, 2006, 10:34 PM
#5
Thread Starter
Member
Re: How to select the picture/image object in Excel worksheet
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|