Sub AdjustImageSize()
Dim doc As Document
Dim img As InlineShape
Dim shape As shape
Dim docWidth As Single
Set doc = ActiveDocument
docWidth = doc.PageSetup.PageWidth - doc.PageSetup.LeftMargin - doc.PageSetup.RightMargin
' Loop through all inline shapes (embedded images)
For Each img In doc.InlineShapes
If img.Width > docWidth Then
img.LockAspectRatio = msoTrue
img.Width = docWidth
End If
Next img
' Loop through all floating shapes (floating images)
For Each shape In doc.Shapes
If shape.Type = msoPicture Or shape.Type = msoLinkedPicture Then
If shape.Width > docWidth Then
shape.LockAspectRatio = msoTrue
shape.Width = docWidth
End If
End If
Next shape
End SubTuesday, December 24, 2024
VBA Word - Adjust all images in Word document
The following VBA code adjusts images in Word document:
Subscribe to:
Post Comments (Atom)
Hot Topics
-
In the previous post we have learnt about SSMS (SQL Server Management Studio) and how to connect with a SQL Server instance. In this post w...
-
By Ajeet Kumar RADAR CHART In radar chart, the categorical variable is displayed as spikes radiating from a central point. The values o...
-
In previous post , we learnt basic introduction to SQL Server . In this post we will learn about SSMS (SQL Server Management Studio) softwar...
No comments:
Post a Comment