Cropping an image in Powerpoint using 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.
开发者_JAVA技巧Can anyone offer any advice?
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://learn.microsoft.com/en-us/office/vba/api/powerpoint.pictureformat.cropbottom
精彩评论