Word VBA批量修改圖片大小


Alt+F11/F8

這部分要說的是把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

Sub 圖片尺寸一起調()
'
'
圖片尺寸一起調 '
'
Mywidth = 15 '10
為圖片寬度(厘米)
' Myheigth = 10 '10
為圖片高度(厘米)
For Each iShape In ActiveDocument.InlineShapes
' iShape.Height = 28.345 * Myheigth
iShape.Width = 28.345 * Mywidth
Next iShape
End Sub


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM