PDA

View Full Version : Crop image to 16:9 ratio



clemleb
11-18-2020, 03:50 AM
Hello everyone,

I would like to create a macro to crop the selected image to 16:9 ratio (as we can do in crop / aspect ratio / 16:9)
Then put my image aligned top, left
Then resize it to my slide settings (here 32 cm*18 cm = 16/9)

I guess the code should look like something like this but I don't get which values I should have for the pictureFormat.Crop



Sub Resize()
With ActiveWindow.Selection.ShapeRange


.PictureFormat.CropLeft = ?
.PictureFormat.CropTop = ?
.PictureFormat.CropRight = ?
.PictureFormat.CropBottom = ?

.Height = 18 * 28.346
.Width = 32 * 28.346
.Left = 0 * 28.346
.Top = 0 * 28.346


End With
End Sub

Thank you very much,

John Wilson
11-19-2020, 08:53 AM
This is cross posted. There are answers here
https://answers.microsoft.com/en-us/msoffice/forum/all/vba-to-crop-image-to-169-ratio/e0405c67-65d0-48c6-8534-b8188c8e680e