1,单击文件
2.
3. 如下图,最后确定
4. 如图
5. 在弹出框中点击创建,
6. 将宏命令 copy 到命令窗口中并点击运行即可,也无需保存
注意,n 需要替换为实际值:如 15代码中单位厘米
(1)设置固定大小 n 厘米:
(2)等比例缩放 n 倍:
Sub resetImgSize()
Dim iShape As InlineShape
For Each iShape In ActiveDocument.InlineShapes
iShape.LockAspectRatio = msoTrue
iShape.Height = CentimetersToPoints(n)
iShape.Width = CentimetersToPoints(n)
Next
End Sub
(3)最大宽度 n 厘米等比例缩放:
Sub resetImgSize()
Dim imgHeight
Dim imgWidth
Dim iShape As InlineShape
For Each iShape In ActiveDocument.InlineShapes
iShape.LockAspectRatio = msoTrue
imgHeight = iShape.Height
imgWidth = iShape.Width
iShape.Height = CentimetersToPoints(n * imgHeight)
iShape.Width = CentimetersToPoints(n * imgWidth)
Next
End Sub
Sub resetImgSize()
Dim imgHeight
Dim imgWidth
Dim iShape As InlineShape
For Each iShape In ActiveDocument.InlineShapes
iShape.LockAspectRatio = msoTrue
imgHeight = iShape.Height
imgWidth = iShape.Width
iShape.Height = CentimetersToPoints(n * imgHeight / imgWidth)
iShape.Width = CentimetersToPoints(n)
Next
End Sub
来源: http://www.bubuko.com/infodetail-2462726.html