Search code examples
vbaoffice-2007ms-word

Word 2007 VBA cannot control Pictures?


Try recording a macro in Word 2007, notice you can't do a thing to pictures. (Or is this a local issue with my machine?)

And I can't even find the Picture / Image object within the Word Object Ref.

What gives?


Solution

  • In Word, images are internally handles as shapes. There are basically two types: InlineShapes, which are aligned inline with the text, and Shapes which are all shapes floating on a page.

    You can access an image depending on its type either via

    With ActiveDocument.InlineShapes(1)
        .Width = 300
        .Height = 200
    End With
    

    or

    With ActiveDocuments.Shapes(1)
        .Width = 300
        .Height = 200
    End With