在撰写论文、制作报告或整理资料时,经常需要插入大量图片。但这些图片尺寸不一,影响整体排版美观。本文将介绍几种在 Microsoft 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
If shp.Type = msoPicture Then
shp.LockAspectRatio = msoFalse
shp.Height = height
shp.Width = width
End If
Next shp
' 调整嵌入式图片
For Each ilshp In ActiveDocument.InlineShapes
If ilshp.Type = wdInlineShapePicture Then
ilshp.LockAspectRatio = msoFalse
ilshp.Height = height
ilshp.Width = width
End If
Next ilshp
End Sub
Alt + F8,运行 ResizeAllImages 宏。⚠️ 注意:请先备份文档,并根据实际需求修改代码中的宽高值。