Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cropping an image in Powerpoint using VBA

Tags:

vba

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?

like image 290
Paul Ellery Avatar asked Nov 02 '09 10:11

Paul Ellery


People also ask

How do you crop a custom picture in PowerPoint?

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.

Can you crop images in PowerPoint?

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.

How do I permanently crop a picture in PowerPoint?

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.

How do I crop to a specific size in PowerPoint?

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).


1 Answers

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

like image 72
Paul Ellery Avatar answered Sep 20 '22 08:09

Paul Ellery