Skip to content

Latest commit

 

History

History
58 lines (39 loc) · 1.83 KB

Excel.Graphic.CropRight.md

File metadata and controls

58 lines (39 loc) · 1.83 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Graphic.CropRight property (Excel)
vbaxl10.chm694078
vbaxl10.chm694078
Excel.Graphic.CropRight
2954d5c9-9b24-db6e-06b7-e3a6e905e50c
04/26/2019
medium

Graphic.CropRight property (Excel)

Returns or sets the number of points that are cropped off the right side of the specified picture or OLE object. Read/write Single.

Syntax

expression.CropRight

expression An expression that returns a Graphic object.

Remarks

Cropping is calculated relative to the original size of the picture. For example, if you insert a picture that is originally 100 points wide, rescale it so that it's 200 points wide, and then set the CropRight property to 50, 100 points (not 50) will be cropped off the right side of your picture.

Example

This example crops 20 points off the right side of shape three on myDocument. For this example to work, shape three must be either a picture or an OLE object.

Set myDocument = Worksheets(1) 
myDocument.Shapes(3).PictureFormat.CropRight = 20

Using the following example, you can specify the percentage that you want to crop off the right side of the selected shape, regardless of whether the shape has been scaled. For the example to work, the selected shape must be either a picture or an OLE object.

percentToCrop = InputBox( _ 
 "What percentage do you want to crop" & _ 
 " off the right of this picture?") 
Set shapeToCrop = ActiveWindow.Selection.ShapeRange(1) 
With shapeToCrop.Duplicate 
 .ScaleWidth 1, True 
 origWidth = .Width 
 .Delete 
End With 
cropPoints = origWidth * percentToCrop / 100 
shapeToCrop.PictureFormat.CropRight = cropPoints

[!includeSupport and feedback]