Visual Basic Macro in Word to Resize / Center / Delete All Images

I found an online VBA macro that resizes all images in a Word document:

Sub ResizeAllImages()
''# make all images (both inline and floating)
''# 11 cm wide while preserving aspect ratio

Dim oShp As Shape
Dim oILShp As InlineShape

For Each oShp In ActiveDocument.Shapes
    With oShp
        .Height = AspectHt(.Width, .Height, _
        CentimetersToPoints(11))
        .Width = CentimetersToPoints(11)
    End With
Next

For Each oILShp In ActiveDocument.InlineShapes
    With oILShp
        .Height = AspectHt(.Width, .Height, _
        CentimetersToPoints(11))
        .Width = CentimetersToPoints(11)
    End With
Next
End Sub

I could not find the name of the method that I could use to center all the images. Does anyone know what I need to add, and where should I add it?

Finally, I would like to remove images that I find too small. How would I do ... If the width of the shape is less than 5 and the height of the shape is less than 5, delete the shape.

, . , -, . , . , , .

+5
3

, . . , - :

For Each oILShp In ActiveDocument.InlineShapes
    oILShp.Select
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Next

Delete Shape, .

+3

:

Sub DeleteSmallPictures()
Dim iShp As InlineShape

    For Each iShp In ActiveDocument.InlineShapes
        With iShp
            If .Width < CentimetersToPoints(5) Then
                iShp.Delete
            End If
        End With
    Next iShp
End Sub
+1

http://yuriy-okhmat.blogspot.co.uk/2011/07/how-to-resize-all-images-in-word.html

Does it have full code, including an AspectHt definition

+1
source

All Articles