Crop a picture in Powerpoint
Posted on 2011-02-13
I would like to know what is wrong with my code below as the cropped image does not end up the right size.
i need the macro to resize the selected image to 12.71cm wide, then to crop off evenly from the top and bottom the left over image above the required height, 3.4cm. There may be instances where the original image is portrait shape but regardless, its needing to be 3.4 x 12.71 in the end.
Dim oSlide As Slide
Dim oPicture As Shape
Dim oshpR As ShapeRange
Dim fd As FileDialog
Dim strFile As String
Dim sngCropSize As Single
' Set oSlide to the first slide in the presentation.
Set oSlide = ActiveWindow.View.Slide
Set oPicture = ActiveWindow.Selection.ShapeRange(1)
oPicture.Width = 363.14
sngCropSize = oPicture.Height - 97.14
oPicture.PictureFormat.CropTop = sngCropSize / 2
oPicture.PictureFormat.CropBottom = sngCropSize / 2
Set oshpR = oSlide.Shapes.Range(Array(oPicture.Name))