Link to home
Start Free TrialLog in
Avatar of Cadberry
Cadberry

asked on

How do I resize images using vba code (powerpoint 2010) so they are center scaled?

I've written vba code to reduce the width of all images in a deck by 25%. But they default to reducing these images by the right side. How can I incorporate into my code that the images scale back 25% from their center and not the right side. I know there is a vba term ScaleFromMiddle but don't know how to incorporate it into my code.
Thank you.

Sub Scale()
Dim Sl As Slide
Dim Sh As Shape
For Each Sl In ActivePresentation.Slides
    For Each Sh In Sl.Shapes
        Sh.LockAspectRatio = False
    Next
Next
Dim oshp As Shape
Dim osld As Slide
Dim dblscaleamount As Double

dblscaleamount = 0.75
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoPicture Or _
   oshp.Type = msoChart Or _
   oshp.Type = msoTable Or _
   oshp.Type = msoAutoShape Or _
   oshp.Type = msoGroup Then
oshp.width = oshp.width * dblscaleamount
oshp.Height = oshp.Height
End If
Next oshp
Next osld
End Sub
Avatar of aikimark
aikimark
Flag of United States of America image

SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yep Scale is a vba reserved word like Print, Byte, Dim etc.

I have tries several times to get a full list but it doesn't seem to exist.
Glad it's not just me JSRWilson!
Avatar of Cadberry
Cadberry

ASKER

Thank you all! These are fantastic solutions.
I was being stubborn and trying to figure out how to have IncrementLeft = 12.5% of the image width as an alternative to ScaleFromMiddle but finally had to cede that it wasn't working.  Thank you all again and apologize for the delayed response.