Sub 批量调整图片大小()
On Error Resume Next
Dim w As single
Dim h As single
w = InputBox("请输入批量调整图片的宽度(厘米),0为不调整宽度,只调整高度", , 0)
h = InputBox("请输入批量调整图片的高度(厘米),0为不调整高度,只调整宽度", , 0)
'如果高宽都为0,则退出'
If w = 0 And h = 0 Then
MsgBox ("未输入宽度,也未输入高度")
Exit Sub
End If
'本段代码批量调整普通图片
Dim myPic As Shape
For Each myPic In ActiveDocument.Shapes
If myPic.Type = msoPicture Then '只调整图片,避免调整形状,公式,图表等类型'
myPic.Select
If w > 0 Then
myPic.Width = 28.345 * w
ElseIf h > 0 Then
myPic.Height = 28.345 * h
End If
End If
Next
'本段代码批量调整嵌入式图片
Dim myinPic As InlineShape
For Each myinPic In ActiveDocument.InlineShapes
myinPic.Select
If w > 0 Then
myinPic.Width = 28.345 * w
ElseIf h > 0 Then
myinPic.Height = 28.345 * h
End If
Next
End Sub
word 批量调整图片大小 VBA
最新推荐文章于 2024-11-13 14:54:27 发布