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
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
I have tries several times to get a full list but it doesn't seem to exist.
Glad it's not just me JSRWilson!
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.
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.
http:A_13519-Printing-many-large-images-in-MS-Access-reports.html
http:A_13837-Placing-a-high-performance-slideshow-on-an-MS-Access-Form.html
http:A_13779-More-Fun-with-Really-Large-High-Fidelity-Images-in-Access-Reports.html