Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Determining Picture Size in a Macro.

Determining Picture Size in a Macro

Written by Allen Wyatt (last updated July 11, 2026)

1

Word keeps quite a bit of information together about the images that you insert in your documents. This information is necessary so that Word knows how to size, position, and display images. If you want to find out more information about the images in your document, then you need to know something about how Word stores the information.

Images are stored as either of two types of graphic objects: regular shapes or inline shapes. Regular shapes are those that reside on the drawing layer, as opposed to inline shapes, which reside in the text layer. Both types of objects are stored with different object collections. Regular shapes are in the Shapes collection, and inline shapes are stored in the InlineShapes collection. To access information about the objects, you just need to use a little VBA.

The following VBA macro creates a document that displays the size of all the graphics objects within a document, in both points and pixels:

Sub FigureInfo()
    Dim iShapeCount As Integer
    Dim iILShapeCount As Integer
    Dim DocThis As Document
    Dim J As Integer
    Dim sTemp As String

    Set DocThis = ActiveDocument
    Documents.Add

    iShapeCount = DocThis.Shapes.Count
    If iShapeCount > 0 Then
        Selection.TypeText Text:="Regular Shapes"
        Selection.TypeParagraph
    End If
    For J = 1 To iShapeCount
        Selection.TypeText Text:=DocThis.Shapes(J).Name
        Selection.TypeParagraph
        sTemp = "     Height (points): "
        sTemp = sTemp & DocThis.Shapes(J).Height
        Selection.TypeText Text:=sTemp
        Selection.TypeParagraph
        sTemp = "     Width (points): "
        sTemp = sTemp & DocThis.Shapes(J).Width
        Selection.TypeText Text:=sTemp
        Selection.TypeParagraph
        sTemp = "     Height (pixels): "
        sTemp = sTemp & PointsToPixels(DocThis.Shapes(J).Height, True)
        Selection.TypeText Text:=sTemp
        Selection.TypeParagraph
        sTemp = "     Width (pixels): "
        sTemp = sTemp & PointsToPixels(DocThis.Shapes(J).Width, False)
        Selection.TypeText Text:=sTemp
        Selection.TypeParagraph
        Selection.TypeParagraph
    Next J

    iILShapeCount = DocThis.InlineShapes.Count
    If iILShapeCount > 0 Then
        Selection.TypeText Text:="Inline Shapes"
        Selection.TypeParagraph
    End If
    For J = 1 To iILShapeCount
        Selection.TypeText Text:="Shape " & J
        Selection.TypeParagraph
        sTemp = "     Height (points): "
        sTemp = sTemp & DocThis.InlineShapes(J).Height
        Selection.TypeText Text:=sTemp
        Selection.TypeParagraph
        sTemp = "     Width (points): "
        sTemp = sTemp & DocThis.InlineShapes(J).Width
        Selection.TypeText Text:=sTemp
        Selection.TypeParagraph
        sTemp = "     Height (pixels): "
        sTemp = sTemp & PointsToPixels(DocThis.InlineShapes(J).Height, True)
        Selection.TypeText Text:=sTemp
        Selection.TypeParagraph
        sTemp = "     Width (pixels): "
        sTemp = sTemp & PointsToPixels(DocThis.InlineShapes(J).Width, False)
        Selection.TypeText Text:=sTemp
        Selection.TypeParagraph
        Selection.TypeParagraph
    Next J
End Sub

Note that the macro returns the names of regular shapes, but not the names of inline shapes. The reason for this is that Word doesn't maintain the names of inline shapes. When you insert a regular shape in your document (again, on the drawing layer), then Word assigns a name to the shape, such as Rectangle 2 or Oval 3.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (8343) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word here: Determining Picture Size in a Macro.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Converting to Automatic Endnotes

When you add endnotes to a document, they are automatically maintained and renumbered by Word, as necessary. If you get a ...

Discover More

Using Drag-and-Drop to Create a Hyperlink

If you open workbooks in two instances of Excel, you can use drag-and-drop techniques to create hyperlinks from one ...

Discover More

Swapping Two Strings

Part of developing macros is learning how to use and manipulate variables. This tip examines a technique you can use to ...

Discover More

Discover the Power of Microsoft Office This beginner-friendly guide reveals the expert tips and strategies you need to skyrocket your productivity and use Office 365 like a pro. Mastering software like Word, Excel, and PowerPoint is essential to be more efficient and advance your career. Simple lessons guide you through every step, providing the knowledge you need to get started. Check out Microsoft Office 365 For Beginners today!

More WordTips (ribbon)

Best Quality for High Resolution Graphics

You want your documents to look as good as they can. If those documents include graphics, then you also need to make sure ...

Discover More

Replacing an Image Filename with the Actual Image

Want to insert a whole bunch of images in your document all at once? The macro in this tip shows you how easy it is to ...

Discover More

Stop Graphics and Text from Jumping Around

Do you struggle with getting your graphics and surrounding text to appear just the way you want it? Here are some ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 - 5?

2026-07-13 09:56:12

Koos van der Weele

The macro has a few problems: It lists the size of other objects as well, and it doen't find all images.

An InlineShape and a Shape can be a lot of things, for example an OLE object (see https://learn.microsoft.com/en-us/office/vba/api/word.wdinlineshapetype and https://learn.microsoft.com/en-us/office/vba/api/office.msoshapetype). So you would need a test on the Type property to make sure it is an image you're dealing with.

For the InlineShapes this could be done by adding a test to the second part of the macro something like this:

If DocThis.InlineShapes(j).Type = wdInlineShapePicture Or DocThis.InlineShapes(j).Type = wdInlineShapeLinkedPicture Then

It gets more compiicated for the Shapes, because a Shape can be a textbox that itself contains images (always in the form of inline shapes) and those images are not part of the InlineShapes collection of the document. Even worse, a Shape can be a group that consists of images (always regular shapes) and/or textboxes, which in turn could also contain images. Dealing with these situations within the structure of the macro would be quite tricky. A better solution is to write a function that returns a Collection of all the images in the document (I'm using Word 2016, so I can't guarantee that it will work in other versions):

Function PicturesColl(doc As Document) As Collection

' Return a Collection with all Picture-shapes in document doc

Dim coll As New Collection

PicturesColl_InlineShapes doc.InlineShapes, coll
PicturesColl_Shapes doc.shapes, coll

Set PicturesColl = coll

End Function

Private Sub PicturesColl_InlineShapes(shps As InlineShapes, coll As Collection)

Dim s As Object

For Each s In shps
If s.Type = wdInlineShapePicture Or s.Type = wdInlineShapeLinkedPicture Then
coll.Add s
End If
Next s

End Sub

Private Sub PicturesColl_Shapes(shps, coll As Collection)

Dim s As Object

For Each s In shps
Select Case s.Type
Case msoPicture, msoLinkedPicture
coll.Add s
Case msoTextBox
PicturesColl_InlineShapes s.TextFrame.TextRange.InlineShapes, coll
Case msoGroup
PicturesColl_Shapes s.GroupItems, coll
End Select
Next s

End Sub

Then the actual macro looks like this:

Sub FigureInfo()

Dim ThisDoc As Document
Dim img As Object
Dim j As Integer ' Counter InlineShapes
Dim s As String

Set ThisDoc = ActiveDocument
Documents.Add
j = 0

For Each img In PicturesColl(ThisDoc)
With img
Select Case TypeName(img)
Case "InlineShape"
j = j + 1
s = "Shape " & j & " on page "
s = s & .Range.Information(wdActiveEndPageNumber)
Case "Shape"
s = .Name & " on page "
s = s & .Anchor.Information(wdActiveEndPageNumber)
End Select
Selection.TypeText s
Selection.TypeParagraph
Selection.TypeText Text:=" Height (points): " & .Height
Selection.TypeParagraph
Selection.TypeText Text:=" Width (points): " & .Width
Selection.TypeParagraph
Selection.TypeText Text:=" Height (pixels): " & PointsToPixels(.Height, True)
Selection.TypeParagraph
Selection.TypeText Text:=" Width (pixels): " & PointsToPixels(.Width, False)
Selection.TypeParagraph
Selection.TypeParagraph
End With
Next img

End Sub

For easy reference the macro adds the pagenumber for each image. It would be nice if the list was sorted according to pagenumber, but i leave that as an exercise for the reader ;-)


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.