Excel) (PictureFormat.CropRight 属性

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

语法

表达式。CropRight

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

备注

裁剪尺寸是相对于图片的原始尺寸计算的。 例如,如果插入的图片最初宽度为 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 支持和反馈,获取有关如何接收支持和提供反馈的指南。