Resize and rotate all images in a Word 2010 document

Just a little snippet to resize and rotate all images in a Word 2010 document. I needed it to create a table with multiple images per row/column from some dragged and dropped images.
Option Explicit
Sub ResizeAndRotateAllImages()

Const ROTATION = 90
Const HEIGHT = 7

Dim n As Integer

For n = 1 To ActiveDocument.InlineShapes.Count
With ActiveDocument.InlineShapes(1)
.ScaleHeight = HEIGHT
.ConvertToShape
End With
Next n

For n = 1 To ActiveDocument.Shapes.Count
With ActiveDocument.Shapes(1)
.IncrementRotation (ROTATION)
.ConvertToInlineShape
End With
Next n

End Sub

Apparently, you have to convert the inserted images from InlineShape to Shape and back as both types provide different methods (e.g. only Shape offers IncrementRotation).

Über Stefan

Polyglot Clean Code Developer

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert