在撰写论文、制作报告或整理资料时,经常需要在Word文档中插入大量图片。但不同来源的图片尺寸不一,手动一张张调整非常耗时。本文将介绍几种高效方法,帮助你快速批量统一Word文档中所有图片的大小。
这是最高效的批量处理方式,适合有一定操作基础的用户:
Alt + F11 打开VBA编辑器。
Sub ResizeAllImages()
Dim shp As Shape
Dim ilshp As InlineShape
Dim height As Single, width As Single
' 设置目标尺寸(单位:磅,1英寸=72磅)
height = 300 ' 高度
width = 400 ' 宽度
For Each shp In ActiveDocument.Shapes
shp.LockAspectRatio = msoTrue
If shp.Height > shp.Width Then
shp.Height = height
Else
shp.Width = width
End If
Next shp
For Each ilshp In ActiveDocument.InlineShapes
ilshp.LockAspectRatio = msoTrue
If ilshp.Height > ilshp.Width Then
ilshp.Height = height
Else
ilshp.Width = width
End If
Next ilshp
End Sub
Alt + F8,选择 ResizeAllImages 并运行。