How to select only pictures in activesheet
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
How to select only pictures in activesheet
I have worksheets with various types of shapes and I’d like to be able to use code to only select all pictures on activesheet.
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: How to select only pictures in activesheet
You can use this...
Code: Select all
Sub SelectAllPics()
ActiveSheet.Pictures.Select
End Sub
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: How to select only pictures in activesheet
Thanks Rudi, but I tried that last night and it seem to only select command buttons
-
- Administrator
- Posts: 78417
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to select only pictures in activesheet
Please try again. ActiveSheet.Pictures, as the name indicates, is the collection of all pictures on the sheet, not of command buttons.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: How to select only pictures in activesheet
here is a sample workbook that will explain
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78417
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to select only pictures in activesheet
I see. It selects ActiveX controls as well as pictures - not ONLY command buttons as you claimed.
One workaround would be to use Forms command buttons instead of ActiveX controls.
Another is to use the following code:
One workaround would be to use Forms command buttons instead of ActiveX controls.
Another is to use the following code:
Code: Select all
Private Sub CommandButton33_Click()
Dim shp As Shape
Dim f As Boolean
For Each shp In Me.Shapes
Select Case shp.Type
Case msoLinkedPicture, msoPicture
shp.Select Replace:=Not f
f = True
End Select
Next shp
End Sub
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: How to select only pictures in activesheet
I believe this is correct, so if I wish to place within a module and use on active sheet I would then replaced the Me with ActiveSheet
Code: Select all
Dim shp As Shape
Dim f As Boolean
For Each shp In ActiveSheet.Shapes
Select Case shp.Type
Case msoLinkedPicture, msoPicture
shp.Select Replace:=Not f
f = True
End Select
Next shp
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: How to select only pictures in activesheet
Looking into this again, the line does actually select Active-X controls (all types).
That is unusual!
The form controls are not selected though.
Can you by any chance change the Active-X controls to form controls?
That is unusual!
The form controls are not selected though.
Can you by any chance change the Active-X controls to form controls?
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- Administrator
- Posts: 78417
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to select only pictures in activesheet
Yes, that is correct.ABabeNChrist wrote:I believe this is correct, so if I wish to place within a module and use on active sheet I would then replaced the Me with ActiveSheet
Best wishes,
Hans
Hans
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: How to select only pictures in activesheet
Hans,
Why use the Boolean variable?
It seems to work with:
shp.Select Replace:=False
Why use the Boolean variable?
It seems to work with:
shp.Select Replace:=False
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: How to select only pictures in activesheet
Thank you Hans, with the code you provided it seems to work perfectly now.
-
- Administrator
- Posts: 78417
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to select only pictures in activesheet
@Rudi: If a shape had already been selected before running the code, it would be included in the selection.
The Boolean variable is used to ensure that the first shape is not added to the selection, but is selected by itself.
The Boolean variable is used to ensure that the first shape is not added to the selection, but is selected by itself.
Best wishes,
Hans
Hans
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: How to select only pictures in activesheet
TX. That clarifies it
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: How to select only pictures in activesheet
I’m using this code to select all photos on activesheet and it works great. But when trying to compress multiple photos in excel 2010 or 2013 it doesn’t seem to give an option for selecting more than a single photo (apply only to this picture) as with 2007 it gives you an option to apply to selected pictures only. Any suggestions.
Code: Select all
Private Sub CommandButton33_Click()
Dim shp As Shape
Dim f As Boolean
For Each shp In Me.Shapes
Select Case shp.Type
Case msoLinkedPicture, msoPicture
shp.Select Replace:=Not f
f = True
End Select
Next shp
End Sub
-
- Administrator
- Posts: 78417
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to select only pictures in activesheet
When I click the button to select ALL pictures, this is the dialog I see when I click Compress Pictures in Excel 2010:
And this is the version I get when I select only a single picture, then click Compress Picture:
And this is the version I get when I select only a single picture, then click Compress Picture:
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: How to select only pictures in activesheet
Thank you Hans I only have 2007 and most of my other experiences are either thru internet search or other users. For some reason it does seem to compress as nicely in 2010/2013 as with 2007 or at least that is my experience.
Are 2010 and 2013 similar with compressing pictures
Are 2010 and 2013 similar with compressing pictures
-
- Administrator
- Posts: 78417
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to select only pictures in activesheet
I don't have 2013, but I assume it's similar to 2010.
Best wishes,
Hans
Hans
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: How to select only pictures in activesheet
2013 is the same as 2010.
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- SilverLounger
- Posts: 1868
- Joined: 25 Jan 2010, 14:00
- Location: Conroe, Texas
Re: How to select only pictures in activesheet
Thank you Rudi
I’m wondering what is the equal to “Apply to selected pictures only” as with 2007, when selecting multiple pictures.
It seems that “Selected Pictures” option is greyed out in 2010/2013
I’m wondering what is the equal to “Apply to selected pictures only” as with 2007, when selecting multiple pictures.
It seems that “Selected Pictures” option is greyed out in 2010/2013
-
- Administrator
- Posts: 78417
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to select only pictures in activesheet
I did some testing in Excel 2010.
It turns out that the label "Apply only to this picture" is slightly misleading - it should actually be "Apply only to the selected picture(s)": if you have selected several pictures, and if the "Apply only to this picture" check box is ticked, all selected pictures will be compressed. If you clear the check box, all pictures in the entire workbook will be compressed.
It turns out that the label "Apply only to this picture" is slightly misleading - it should actually be "Apply only to the selected picture(s)": if you have selected several pictures, and if the "Apply only to this picture" check box is ticked, all selected pictures will be compressed. If you clear the check box, all pictures in the entire workbook will be compressed.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans