gpt4 book ai didi

vba - 将 word 文档中的所有图像缩放到 100% 的脚本

转载 作者:行者123 更新时间:2023-12-04 18:12:55 24 4
gpt4 key购买 nike

我得到包含图像的 word 2010 文档。现在由于某种原因,这些图像被缩放到 133%。

现在我正在寻找一种方法来遍历文档中的所有图像并将它们缩放到 100%。我找到了这个脚本,但它不起作用(我对单词宏一无所知,所以我不知道为什么):

Sub AllGraphicsTo100() 

Dim ILS As Word.InlineShape
Dim SHP As Word.Shape

For Each ILS In ActiveDocument.InlineShapes
If ILS.Type = wdInlineShapePicture Then
ILS.ScaleHeight = 100
ILS.ScaleWidth = 100
End If
Next ILS

For Each SHP In ActiveDocument.Shapes
If SHP.Type = msoPicture Then
SHP.ScaleHeight 1#, True
SHP.ScaleWidth 1, True
End If
Next SHP

End Sub

此外,如果图像比列宽,我想缩放它们以适应列的宽度而不是 100%。

最佳答案

您的图像可能是链接的,而不是嵌入的。您可以修改宏以包含链接图像,如下所示:

    Sub AllGraphicsTo100()

Dim ILS As Word.InlineShape
Dim SHP As Word.Shape

For Each ILS In ActiveDocument.InlineShapes
If ILS.Type = wdInlineShapePicture Or ILS.Type = wdInlineShapeLinkedPicture Then
ILS.ScaleHeight = 100
ILS.ScaleWidth = 100
End If
Next ILS

For Each SHP In ActiveDocument.Shapes
If SHP.Type = msoPicture Or SHP.Type = msoLinkedPicture Then
SHP.ScaleHeight 1#, True
SHP.ScaleWidth 1, True
End If
Next SHP

End Sub

关于vba - 将 word 文档中的所有图像缩放到 100% 的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12259726/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com