word 宏 图片相关
图片剪裁
已知一个图片,在选中图片的情况下,用宏剪裁
Sub crop()
left_cut = 0
right_cut = 0
top_cut = 9 ' 3times u want
bottom_cut = 0
pic_height = 2 'final height
pic_width = 14.86
On Error Resume Next '
scales = 1 / 0.03528 'convert unit to cm
If Selection.InlineShapes.Count > 0 Then
With Selection.InlineShapes(1).PictureFormat
.CropBottom = bottom_cut * scales
.CropLeft = left_cut * scales
.CropRight = right_cut * scales
.CropTop = top_cut * scales
End With
'Selection.InlineShapes(1).LockAspectRatio = msoFalse
'Selection.InlineShapes(1).Height = pic_height * scales
' Selection.InlineShapes(1).Width = pic_width * scales
Else
With Selection.ShapeRange(1).PictureFormat
.CropBottom = bottom_cut * scales
.CropLeft = left_cut * scales
.CropRight = right_cut * scales
.CropTop = top_cut * scales
End With
'Selection.ShapeRange(1).LockAspectRatio = msoTrue
'Selection.ShapeRange(1).Height = pic_height * scales
'Selection.ShapeRange(1).Width = pic_width * scales
End If
End Sub