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

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax