Reset Size of pasted thumbnails through VBA

Orada

New Member
Joined
Mar 28, 2011
Messages
18
This should be simple but I'm not seeing it and even the Macro recorder doesn't give me a long winded solution.

I have information which has been pasted into a worksheet and column 2 contains essentially thumbnail images default size 1.96cm x 1.43cm. The problem is that the aspect ratio of some of these thumbnails has been distorted due to the sizing of adjacent pasted columns.

What I would like to achieve through VBA is - Select all Images > Format Picture > Size > Reset.

Thanks in advance.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try...

Code:
[color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] ResetImagesToOriginalSize()

    [color=darkblue]Dim[/color] oShape [color=darkblue]As[/color] Shape
    
    [color=darkblue]For[/color] [color=darkblue]Each[/color] oShape [color=darkblue]In[/color] ActiveSheet.Shapes
        [color=darkblue]If[/color] oShape.Type = msoPicture [color=darkblue]Then[/color]
            oShape.ScaleWidth 1, msoTrue, msoScaleFromTopLeft
            oShape.ScaleHeight 1, msoTrue, msoScaleFromTopLeft
        [color=darkblue]End[/color] [color=darkblue]If[/color]
    [color=darkblue]Next[/color]
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]

Hope this helps!
 
Upvote 0
Try...

Code:
[color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] ResetImagesToOriginalSize()

    [color=darkblue]Dim[/color] oShape [color=darkblue]As[/color] Shape
    
    [color=darkblue]For[/color] [color=darkblue]Each[/color] oShape [color=darkblue]In[/color] ActiveSheet.Shapes
        [color=darkblue]If[/color] oShape.Type = msoPicture [color=darkblue]Then[/color]
            oShape.ScaleWidth 1, msoTrue, msoScaleFromTopLeft
            oShape.ScaleHeight 1, msoTrue, msoScaleFromTopLeft
        [color=darkblue]End[/color] [color=darkblue]If[/color]
    [color=darkblue]Next[/color]
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]

Hope this helps!

Perfect Domenic, thank you so much, now to drive to another learning difficulty :)
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top