在编辑Word文档时,经常需要插入多张图片,但这些图片尺寸不一,影响整体排版美观。本文将介绍几种实用方法,帮助你快速统一调整Word中所有图片的大小。
Ctrl 键,依次点击每一张要调整的图片,实现多选。若文档中图片数量较多,手动操作效率低,可使用以下VBA宏代码一键统一尺寸:
Sub ResizeAllPictures()
Dim shp As Shape
Dim ilshp As InlineShape
Dim targetWidth As Single
Dim targetHeight As Single
' 设置目标尺寸(单位:磅,1英寸=72磅)
targetWidth = 300 ' 宽度设为300磅(约10.5厘米)
targetHeight = 200 ' 高度设为200磅(约7厘米)
' 调整浮动型图片
For Each shp In ActiveDocument.Shapes
If shp.Type = msoPicture Then
shp.LockAspectRatio = msoTrue
If shp.Width > shp.Height Then
shp.Width = targetWidth
Else
shp.Height = targetHeight
End If
End If
Next shp
' 调整嵌入型图片
For Each ilshp In ActiveDocument.InlineShapes
If ilshp.Type = wdInlineShapePicture Then
ilshp.LockAspectRatio = msoTrue
If ilshp.Width > ilshp.Height Then
ilshp.Width = targetWidth
Else
ilshp.Height = targetHeight
End If
End If
Next ilshp
End Sub
使用步骤:
Alt + F11 打开VBA编辑器。F5 运行宏,即可自动统一所有图片尺寸。Esc 退出格式刷模式。