Excel) (Graphic.CropRight 属性

返回或设置从指定图片或 OLE 对象的右侧裁剪的 数。 读/写 Single

语法

表达式CropRight

表达 返回 Graphic 对象的表达式。

备注

裁剪尺寸是相对于图片的原始尺寸计算的。 例如,如果插入的图片最初为 100 磅宽,请将其重新缩放为 200 磅宽,然后将 CropRight 属性设置为 50,100 磅 (不是 50 磅) 将从图片的右侧裁剪。

示例

此示例在 myDocument 中第三个形状的右侧裁剪了 20 磅。 仅当该图形是图片或 OLE 对象时,本示例才有效。

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

使用以下示例,可以指定要从所选形状右侧裁剪的百分比,而不管形状是否已缩放。 为了使本示例生效,选定形状必须是图片或 OLE 对象。

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

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。