I need to crop an image on a Powerpoint slide using VBA - in my particular case I'm cropping from the top and left edges.
Can anyone offer any advice?
Select the picture (or pictures) that you want to crop. On the PICTURE TOOLS FORMAT tab, click Crop > Crop to Shape, and then pick the shape you want.
On the Format tab, click the Crop command. Cropping handles will appear around the image. Click and drag one of the handles to crop the image. Make sure the mouse is right over the black cropping handle so you don't accidentally select a resizing handle.
Use Insert > Pictures to add the image to an Office file (such as a Word document, PowerPoint presentation, or Excel workbook). Click the picture, then click the Picture Format tab on the toolbar ribbon. On the Picture Format tab, select Crop. Black crop handles appear on the edges and corners of the picture.
In Normal View or Slide Master View, select the picture you want to crop. Click the Picture Tools Format or Picture Format tab in the Ribbon and in the Size group, click the arrow below Crop. From the drop-down menu, choose Aspect Ratio and then select an aspect ratio (such as 16:9).
The following commands will crop 10 points off of each edge of the shape:
With ActivePresentation.Slides(1).Shapes(1)
.PictureFormat.CropLeft = 10
.PictureFormat.CropTop = 10
.PictureFormat.CropRight = 10
.PictureFormat.CropBottom = 10
End With
Note that this will crop shape number 1 on slide 1. If you want to crop the currently selected shape, use the following as the first line instead:
With ActiveWindow.Selection.ShapeRange(1)
See additional information on the CropBottom/etc. properties here: https://docs.microsoft.com/en-us/office/vba/api/powerpoint.pictureformat.cropbottom
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With