你是一个资深的Word使用人员在Word2007中给大量图片自动修改成高388cm、宽43cm排列成每行4张图片并且在每张图片下方中间位置按顺序加上阿拉伯数字的编号要求写出宏代码而且能在Word2007中运行。
Sub ResizeAndNumberImages()
'设置图片大小
Dim width As Long
Dim height As Long
width = CentimetersToPoints(4.3)
height = CentimetersToPoints(3.88)
'设置行和列
Dim rows As Long
Dim cols As Long
rows = 0
cols = 0
'循环遍历所有图片
For Each pic In ActiveDocument.InlineShapes
'调整大小
pic.Width = width
pic.Height = height
'计算行列
If cols = 4 Then
cols = 0
rows = rows + 1
End If
'排列图片
pic.Range.Select
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveRight Unit:=wdCharacter, Count:=width, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=rows, Extend:=wdExtend
Selection.MoveRight Unit:=wdCharacter, Count:=cols * (width + 2), Extend:=wdExtend
'添加编号
Dim num As String
num = rows * 4 + cols + 1
Selection.TypeText Text:=num
Selection.MoveDown Unit:=wdLine, Count:=1
'更新列数
cols = cols + 1
Next pic
End Su
原文地址: https://www.cveoy.top/t/topic/eB7p 著作权归作者所有。请勿转载和采集!