批量处理图片宏代码

代码1 锁定纵横比 (有效)
Sub 统一图片大小()
Dim iShape As InlineShape
For Each iShape In ActiveDocument.InlineShapes
iShape.LockAspectRatio = msoTrue
iShape.Height = CentimetersToPoints(15) /此处数字为厘米单位,非像素/
'iShape.Width = CentimetersToPoints(15)
Next
End Sub

代码2 不锁定纵横比 (有效)
Sub setpicsize() '
Dim n '
On Error Resume Next '
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes
ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '
ActiveDocument.InlineShapes(n).Height = 320 '
ActiveDocument.InlineShapes(n).Width = 425 '/经调试后,此处高度和宽度必须很宽,代码内分度值为像素,并非厘米,因为Inline的缘故?/
Next n
End Sub


代码3 不锁定纵横比 /无效,但调试无语法错误/
For n = 1 To ActiveDocument.Shapes.Count 'Shapes
ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '
ActiveDocument.Shapes(n).Height = 3 '
ActiveDocument.Shapes(n).Width = 5 '
Next n
End Sub


代码4 不锁纵横比 (这个有效。代码同2)
Sub setpicsize() '
Dim n '
On Error Resume Next '
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes
ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '
ActiveDocument.InlineShapes(n).Height = 3.5 * 28.35 '
ActiveDocument.InlineShapes(n).Width =5 *28.35 '/同上,前面的3.5和5.5可以理解为像素/
Next n
End Sub


代码5 仅仅解除纵横比
Sub () '
Dim n '
On Error Resume Next '
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes
ActiveDocument.InlineShapes(n).LockAspectRatio = msoFalse '
Next n
End Su


相关文档
最新文档