Word VBA批量修改图片大小
Alt+F11/F8
这部分要说的是把word中的所有图片按比例缩放!
具体操作同上,只是代码部分稍做修改,代码如下:
Sub setpicsize() '设置图片大小
Dim n '图片个数
Dim picwidth
Dim picheight
On Error Resume Next '忽略错误
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes 类型图片
picheight = ActiveDocument.InlineShapes(n).Height
picwidth = ActiveDocument.InlineShapes(n).Width
ActiveDocument.InlineShapes(n).Height = picheight * 1.1 '设置高度为1.1倍
ActiveDocument.InlineShapes(n).Width = picwidth * 1.1 '设置宽度为1.1倍
Next n
For n = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片
picheight = ActiveDocument.Shapes(n).Height
picwidth = ActiveDocument.Shapes(n).Width
ActiveDocument.Shapes(n).Height = picheight * 1.1 '设置高度为1.1倍
ActiveDocument.Shapes(n).Width = picwidth * 1.1 '设置宽度为1.1倍
Next n
End Sub
Sub 图片尺寸一起调()
'
' 图片尺寸一起调
宏'
'
Mywidth = 15 '10为图片宽度(厘米)
' Myheigth = 10 '10为图片高度(厘米)
For Each iShape In ActiveDocument.InlineShapes
' iShape.Height = 28.345 * Myheigth
iShape.Width = 28.345 * Mywidth
Next iShape
End Sub