word中批量修改图片大小的方法
时间:2023-03-20 08:16:02
在word中,我们有时候需要批量修改图片的大小word中批量修改图片大小
方法一:
这部分要说的是把word中的所有图片修改成固定的并且相同的长和宽!
1、打开word,工具-宏-宏(或者直接按Alt+F8)进入宏的 界面,如下面所示,输入一个宏名,宏名自己起,能记住就行!
2、宏名起好了,单击“创建”进入Visual Basic 编辑器,输入如下代码并保存
复制代码代码如下:
Sub setpicsize() '设置图片大小
Dim n ' 图片个数
On Error Resume Next ' 忽略错误
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes 类型图片
ActiveDocument.InlineShapes(n).Height = 400 '设置图片高度为 400px
ActiveDocument.InlineShapes(n).Width = 300 '设置图片宽度 300px
Next n
For n = 1 To ActiveDocument.Shapes.Count 'Shapes 类型图片
ActiveDocument.Shapes(n).Height = 400 '设置图片高度为 400px
ActiveDocument.Shapes(n).Width = 300 '设置图片宽度 300px
Next n
End Sub
3、返回word,工具-宏-宏(或者直接按Alt+F8),再次进入宏的界面,选择刚才编辑好的宏,并单击“运行”按钮,就可以了!(图片多时, 可能会花一些时间)
方法二:
1、在word中按alt+f11组合键,进入VBA模式
2、在左边的工程资源管理器中找到你的word文档,在其上右键/添加/模块
3、把下面代码复制,粘贴进去.
4、更改数值, 改一下宽度和高度数值(10),点运行(类似播放按钮.)或f5,即可设置文档中全部图片
复制代码代码如下:
Sub Macro()
Mywidth=10 ‘10为图片宽度(厘米)
Myheigth=10 ‘10为图片高度(厘米)
For Each iShape In ActiveDocument.InlineShapes
iShape.Height = 28.345 * Myheigth
iShape.Width = 28.345 * Mywidth
Next iShape
End Sub
word批量修改图片大小——按比例缩放篇
这部分要说的是把word中的所有图片按比例缩放!
具体操作同上,只是代码部分稍做修改,代码如下:
复制代码代码如下:
Sub setpicsize() '设置图片大小
Dim n '图片个数
Dim picwidth
Dim picheight
On Error Resume Next '忽略错误
For n = 1 To ActiveDocument.InlineShapes.Count 'InlineShapes 类型图片
picheight = ActiveDocument.InlineShapes(n).Height
picwidth = ActiveDocument.InlineShapes(n).Width
ActiveDocument.InlineShapes(n).Height = picheight * 1.1 '设置高度为1.1倍
ActiveDocument.InlineShapes(n).Width = picwidth * 1.1 '设置宽度为1.1倍
Next n
For n = 1 To ActiveDocument.Shapes.Count 'Shapes类型图片
picheight = ActiveDocument.Shapes(n).Height
picwidth = ActiveDocument.Shapes(n).Width
ActiveDocument.Shapes(n).Height = picheight * 1.1 '设置高度为1.1倍
ActiveDocument.Shapes(n).Width = picwidth * 1.1 '设置宽度为1.1倍
Next n
End Sub
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Excel批量生成和打印考场座位标签实例教程
![](https://img.aspxhome.com/file/2023/8/37798_0s.jpg)
PS怎么去图片水印?PS去除图片中有很多水印的方法教学
![](https://img.aspxhome.com/file/2023/7/a327397_0s.png)
Win10要怎么调节风扇转速?
![](https://img.aspxhome.com/file/2023/1/a278348_0s.png)
PS新手教程-如何使用PS把图片变成黑白的
![](https://img.aspxhome.com/file/2023/0/a202170_0s.jpeg)
利用word制作试卷时,选择题的四个选项怎样严格对齐?
![](https://img.aspxhome.com/file/2023/6/35686_0s.png)
Win7怎么设置开机启动项
![](https://img.aspxhome.com/file/2023/26/a228686_0s.png)
mac上好用的Dock强化工具分享
![](https://img.aspxhome.com/file/2023/10/a343861_0s.jpeg)
苹果电脑,删除键如何长按全部删除?
![](https://img.aspxhome.com/file/2023/30/a264906_0s.jpg)
Win11已连接的蓝牙设备怎么删除?
![](https://img.aspxhome.com/file/2023/27/a237132_0s.jpg)
任务管理器被系统管理员停用怎么解除打开?
![](https://img.aspxhome.com/file/2023/6/a322272_0s.png)
如何用excel求积的方法
Excel 单元格自定义格式 知识图解详细教程
![](https://img.aspxhome.com/file/2023/9/a161839_0s.png)
微软警告:64位Win7系统或无法安装KB3033929补丁更新
![](https://img.aspxhome.com/file/2023/29/a251479_0s.jpg)
Win10笔记本刷新率怎么提高?Win10笔记本刷新率设置方法
![](https://img.aspxhome.com/file/2023/25/a219014_0s.jpg)
wps演示文稿如何添加备注
如何卸载win10更新补丁
![](https://img.aspxhome.com/file/2023/1/a281123_0s.png)
Excel中选择单元格的常用技巧
B612如何调反差色?B612调反色差的方法
![](https://img.aspxhome.com/file/2023/8/a333761_0s.jpg)
苹果Mac不能用Zoom虚拟背景的解决方法分享
![](https://img.aspxhome.com/file/2023/7/a215767_0s.png)
一米阅读如何订购买书?一米阅读订购买书的方法
![](https://img.aspxhome.com/file/2023/8/a332761_0s.jpg)