Last active
February 22, 2016 18:16
-
-
Save joswr1ght/b6b695c66199feb3bc81 to your computer and use it in GitHub Desktop.
Change Image Aspect - Fix broken image aspect change in PowerPoint after converting from 4:3 to 16:9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub changeImageAspect() | |
Dim oshp As Shape | |
Dim osld As Slide | |
' Stupid workaround for no getter for scaleWidth/scaleHeight | |
Dim sHeightOld As Variant | |
Dim sWidthOld As Variant | |
Dim tScaleWidth As Variant | |
Dim tScaleHeight As Variant | |
For Each osld In ActivePresentation.Slides | |
For Each oshp In osld.Shapes | |
Select Case oshp.Type | |
Case msoPicture | |
sHeightOld = oshp.Height | |
sWidthOld = oshp.Width | |
oshp.ScaleWidth 1#, msoTrue | |
oshp.ScaleHeight 1#, msoTrue | |
tScaleHeight = sHeightOld / oshp.Height | |
tScaleWidth = sWidthOld / oshp.Width | |
'Exit Sub | |
' Set the scaleheight back to the original | |
' This makes the image as big as it was originally | |
'oshp.ScaleHeight tScaleWidth, msoTrue | |
' Set the scalewidth to match the scaleheight | |
oshp.ScaleWidth tScaleHeight, msoTrue | |
' Offset left axis to center images | |
oshp.left = oshp.left + 40 | |
End Select | |
Next oshp | |
Next osld | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment