Skip to content

Instantly share code, notes, and snippets.

@joswr1ght
Last active February 22, 2016 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joswr1ght/b6b695c66199feb3bc81 to your computer and use it in GitHub Desktop.
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
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