如何批量修改Word中图片大小和缩放比例的方法介绍
时间:2023-04-11 00:22:18
最近小编遇到一个问题:需要将一篇word文档中的所有图片全部缩小比例。一张张改太麻烦了
最近小编遇到一个问题:需要将一篇word文档中的所有图片全部缩小比例。一张张改太麻烦了。于是从网上搜罗了一下,还真找到了解决办法。需要注意的地方 就是注意厘米与像素的换算关系。一般情况下1厘米=28px 。这个换算关系其实可以用计算器计算出来。计算公式为图片改变之后的像素除以改变之后图片的大小厘米。
固定长宽篇
这部分要说的是把word中的所有图片修改成固定的并且相同的长和宽!
1、打开word,工具-宏-宏(或者直接按Alt+F8)进入宏的界面,如下面所示,输入一个宏名,宏名自己起,能记住就行!
2、宏名起好了,单击“创建”进入Visual Basic 编辑器,输入如下代码并保存
Sub setpicsize() '设置图片大小
Dim n '图片个数
On Error Resume Next '忽略错误
Forn = 1 ToActiveDocument.InlineShapes.Count 'InlineShapes类型图片
ActiveDocument.InlineShapes(n).Height = 400 '设置图片高度为 400px
ActiveDocument.InlineShapes(n).Width = 300 '设置图片宽度 300px
Nextn
Forn = 1 ToActiveDocument.Shapes.Count 'Shapes类型图片
ActiveDocument.Shapes(n).Height = 400 '设置图片高度为 400px
ActiveDocument.Shapes(n).Width = 300 '设置图片宽度 300px
Nextn
End Sub
3、返回word,工具-宏-宏(或者直接按Alt+F8),再次进入宏的界面,选择刚才编辑好的宏,并单击“运行”按钮,就可以了!(图片多时,可能会花一些时间)
按比例缩放篇
这部分要说的是把word中的所有图片按比例缩放!
具体操作同上,只是代码部分稍做修改,代码如下:
Sub setpicsize() '设置图片大小
Dim n '图片个数
Dimpicwidth
Dimpicheight
On Error Resume Next '忽略错误
For n = 1 ToActiveDocument.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倍
Nextn
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倍
Nextn
End Sub
若还想使所有图片居中对齐,可在循环中加入下面的语句:
ActiveDocument.InlineShapes(n).Range.ParagraphFormat.Alignment= wdAlignParagraphCenter
‘左对齐:wdAlignParagraphLeft
注意:这里的Shapes(InlineShapes)不仅仅是指图片,也包含其它的,自选图形、任意多边形、OLE 对象、ActiveX 控件、图片等。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Excel文件变成白板图标怎么办?Win10 Excel文件变成白板图标的解决方法
![](https://img.aspxhome.com/file/2023/28/a239241_0s.jpg)
WPS Table 2013利用高级过滤功能实现空白行的批量删除
![](https://img.aspxhome.com/file/2023/7/a169397_0s.jpg)
惠普暗影精灵5笔记本电脑评测、参数、价格、图片
![](https://img.aspxhome.com/file/2023/4/a305177_0s.jpg)
Win11系统中文输入法变成x怎么办?中文输入法变成x处理方法
![](https://img.aspxhome.com/file/2023/27/a237022_0s.jpg)
Win7提示“由于出现以下错误而无法打印您的图片”如何解决?
![](https://img.aspxhome.com/file/2023/26/a228396_0s.jpg)
word2007中图片或剪辑显示红色X
Win7临时文件在哪里?Win7临时文件存放位置介绍
![](https://img.aspxhome.com/file/2023/26/a228449_0s.png)
Win7电脑怎么进入到安全模式?
![](https://img.aspxhome.com/file/2023/26/a228420_0s.png)
电脑崩溃了怎么一键还原?Win10系统一键还原系统方法
![](https://img.aspxhome.com/file/2023/6/49226_0s.png)
excel表格数列数字乘以2的方法
6个简约创意文字壁纸合集
![](https://img.aspxhome.com/file/2023/7/a204917_0s.jpeg)
安易硬盘数据恢复软件怎么用?安易硬盘数据恢复软件使用方法
![](https://img.aspxhome.com/file/2023/8/a337600_0s.jpg)
Excel中F4键怎么用?
![](https://img.aspxhome.com/file/2023/0/a154310_0s.jpg)
CAD迷你看图怎么转换成PDF?CAD迷你看图转换成PDF的方法
![](https://img.aspxhome.com/file/2023/7/a332577_0s.jpg)
华为移动应用引擎如何运行安卓应用?华为移动应用引擎运行安卓应用的方法
![](https://img.aspxhome.com/file/2023/6/a323919_0s.png)
如何在Word 2013中向文档添加水印?
Adobe Photoshop Elements 2021使用教程:导入照片和视频
![](https://img.aspxhome.com/file/2023/5/a209505_0s.jpeg)
PPT文字怎么围绕圆形图片排列? ppt图文海报的排列方法
![](https://img.aspxhome.com/file/2023/10/a345684_0s.jpg )
如何给excle表格加密?
mathtype公式编辑器怎么打空格?
![](https://img.aspxhome.com/file/2023/5/a315955_0s.jpg)