您的位置:首页 > 聚焦 > 正文
每日讯息!批量修改图片大小excel(批量修改图片大小)
来源:互联网 发布时间2023-06-27 02:06:05    

1、方法1:


(资料图片仅供参考)

2、这部分我想说的是把word里所有的图片都改成固定的,同样的长宽!

3、打开word,工具-宏-宏(或者直接按Alt F8)进入宏界面,如下图。输入一个宏名,自己就能记住了!

4、宏命名后,点击创建进入Visual Basic编辑器,输入以下代码并保存。

5、复制代码

6、代码如下:

7、Sub setpicsize()"设置图片大小。

8、图片的数量

9、Continue to the next step when an error occurs" Ignore the error.

10、对于n=1到活动文档.嵌入式形状。"计数"内嵌形状类型图片

11、ActiveDocument embedded shape. Height=400ft Set the picture height to 400 pixels.

12、ActiveDocument embedded shape. Width=300ft Set the picture width to 300 pixels.

13、Next n

14、For n=1 to ActiveDocument. Shape. Calculate shape type picture

15、ActiveDocument shape (n) Height=400ft Set the picture height to 400 pixels.

16、ActiveDocument shape (n) Width=300ft Set the picture width to 300 pixels.

17、Next n

18、End Sub

19、回到word,工具-宏-宏(或者直接按Alt F8),再次进入宏界面,选择刚才编辑的宏,点击“运行”按钮。

20、方法二:

21、在word中按alt f11进入VBA模式。

22、在左侧的项目浏览器中找到您的word文档,然后右键单击/Add/Module。

23、复制并粘贴以下代码。

24、更改值,更改宽度和高度值(10),然后单击运行(类似于播放按钮。)或f5设置文档中的所有图片。

25、复制代码

26、代码如下:

27、Sub Macro()

28、Mywidth=10 ‘10为图片宽度(厘米)

29、Myheigth=10 ‘10为图片高度(厘米)

30、For Each iShape In ActiveDocument.InlineShapes

31、iShape.Height=28.345 * Myheigth

32、iShape.Width=28.345 * Mywidth

33、Next iShape

34、End Sub

35、word批量修改图片大小——按比例缩放篇

36、这部分要说的是把word中的所有图片按比例缩放!

37、具体操作同上,只是代码部分稍做修改,代码如下:

38、复制代码

39、代码如下:

40、Sub setpicsize() "设置图片大小

41、Dim n "图片个数

42、Dim picwidth

43、Dim picheight

44、On Error Resume Next "忽略错误

45、For n=1 To ActiveDocument.InlineShapes.Count "InlineShapes 类型图片

46、picheight=ActiveDocument.InlineShapes(n).Height

47、picwidth=ActiveDocument.InlineShapes(n).Width

48、ActiveDocument.InlineShapes(n).Height=picheight * 1.1 "设置高度为1.1倍

49、ActiveDocument.InlineShapes(n).Width=picwidth * 1.1 "设置宽度为1.1倍

50、Next n

51、For n=1 To ActiveDocument.Shapes.Count "Shapes类型图片

52、picheight=ActiveDocument.Shapes(n).Height

53、picwidth=ActiveDocument.Shapes(n).Width

54、ActiveDocument.Shapes(n).Height=picheight * 1.1 "设置高度为1.1倍

55、ActiveDocument.Shapes(n).Width=picwidth * 1.1 "设置宽度为1.1倍

56、Next n

57、End Sub

本文到此结束,希望对大家有所帮助。

关键词:

推荐内容