Why this code fails:
Code:
Sub demo()
'works fine
Application.ScreenUpdating = False
Dim iShp As InlineShape
For Each iShp In ActiveDocument.InlineShapes
With iShp.Range
If iShp.Height > 6 Then
iShp.LockAspectRatio = True
iShp.Height = InchesToPoints(6)
If .Hyperlinks.Count = 1 Then
.Hyperlinks(1).Delete
End If
End If
If iShp.Width > 4 Then
iShp.LockAspectRatio = True
iShp.Width = InchesToPoints(4)
If .Hyperlinks.Count = 1 Then
.Hyperlinks(1).Delete
End If
End If
End With
Next
Application.ScreenUpdating = False
End Sub
I want to resize images in the document based on the logic that
1) if the hight of the shape is > 6, make it to 6.
2) if the width of the shape is > 4, make it to 4.
In above code irrespective of size of the shape it executes the code.