word使用宏命令批量按比例设置图片大小

1,单击文件

2.

 

3.如下图,最后确定

 

 

 

 

 4.如图

 

5.在弹出框中点击创建,

 

 6.将宏命令copy到命令窗口中并点击运行即可,也无需保存

注意,n需要替换为实际值:如15

 

 

 

 

 

 

代码中单位厘米

(1)设置固定大小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

(2)等比例缩放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

(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 / imgWidth)
iShape.Width = CentimetersToPoints(n)
Next
End Sub

 

转载于:https://www.cnblogs.com/janwang/p/8289803.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值