Philadelphia Reflections

The musings of a physician who has served the community for over six decades

Related Topics

Pearls on a String:Further Extending Health (and Retirement) Savings Accounts
Pearls on a String: Further Extending Health (and Retirement) Savings Accounts. HSAs are the string. Retirement saving, Privatizing Medicare, and Shifting Childhood Costs-- are the Pearls. Other Pearls to follow.

Co-ordinating Obamacare With Health Savings Accounts

Iterate through a Word document, modifying picture properties(Blog 2300)

(Blog 2300) We have a facility on this website to download books of many chapters (made up of volumes of topics on the site) to Microsoft Word for subsequent editing and eventual publishing. In many cases we download lots of pictures (via an img src= tag). I have not found a way to set the way text flows around the images in Word using HTML or CSS, so I built a Word macro to do it. This should allow you to change the size of images, as well as move them around. Moving the captions requires the use of the captions feature in Word's image menu (right-click).


Instructions for use of a Macro named Sub ImageFlow():

  1. Open Word

  2. In Word, enter File>Open

  3. enter the URL of the file you want to modify into the File Entry box and press the Enter key to load the document. It may take a minute or two, but a working screen should appear, loaded with the file in a condition ready to move the pictures around.

  4. Press Alt + F11 which will open the VBA screen

  5. Copy the macro found on this page from
    Sub ImageFlow()
    End Sub
  6. In the right-hand panel of the VBA screen press Ctrl+A, Ctrl+V to paste it in

  7. In the VBA screen press F5 to run the macro

If you want to do a lot of these manipulations, save the macro in the Macro Library of Windows Word.

Sub ImageFlow()
'  this Macro goes through an entire Word document and
'  changes the way text flows around each picture
'  ("Tight" in this example but see below for choices)
    Dim shpIn As InlineShape, shp As Shape

    For Each shpIn In ActiveDocument.InlineShapes
        If (shpIn.Type = wdInlineShapeLinkedPicture) Then
            Set shp = shpIn.ConvertToShape
            shp.WrapFormat.Type = wdWrapTight
        End If
    Next shpIn

    For Each shp In ActiveDocument.Shapes
        shp.WrapFormat.Type = wdWrapTight
    Next shp

End Sub

Change wdWrapTight to any of the following:

My thanks to for showing me the essential technique of iterating through the pictures.

What are the InlineShapes' Types? See; it is possible we may also need to select on wdInlineShapePicture (as well as wdInlineShapeLinkedPicture) but for my specific purpose I did not need to.

Originally published: Sunday, July 08, 2012; most-recently modified: Wednesday, May 22, 2019