Word宏设置图片大小

Word宏设置图片大小


1. Alt+F8, Create 一个Macro
2. 输入Macro名,进入编辑


---按比例缩小大量图片
Sub alex() '设置图片大小
 Dim n '图片个数
 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 * 0.5 '设置高度为0.5倍
 ActiveDocument.InlineShapes(n).Width = picwidth * 0.5 '设置宽度为0.5倍
 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 * 0.5 '设置高度为0.5倍
 ActiveDocument.Shapes(n).Width = picwidth * 0.5 '设置宽度为0.5倍
 Next n
End Sub






---图片大小设置成绝对值  1cm=28px
Sub alex() '设置图片大小
 Dim n '图片个数
 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 = 280 '设置高度为280px
 ActiveDocument.InlineShapes(n).Width = 364 '设置宽度为364px
 Next n
 For n = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片
 picheight = ActiveDocument.Shapes(n).Height
 picwidth = ActiveDocument.Shapes(n).Width
 ActiveDocument.Shapes(n).Height = 280 '设置高度为280px
 ActiveDocument.Shapes(n).Width = 364 '设置宽度为364px
 Next n
End Sub




3. 保持,再次进入原来的word,alt-f8 run这个宏


标题名称:Word宏设置图片大小
转载源于:http://scyanting.com/article/jespod.html