Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. 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: Searching for Floating Graphics.

Searching for Floating Graphics with a Macro

Written by Allen Wyatt (last updated October 14, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


Word includes some commands and shortcuts that allow you to search for graphics in your documents. Unfortunately, those methods of searching are only good for finding inline graphics. If you want to find floating graphics, you are out of luck; since they are on the graphics layer and not in the actual document, Word pretty much ignores them.

There is a way you can find floating graphics using a macro, however. A macro can examine the floating graphics in your document and select each of them in turn. The following macro does just that:

Sub FindFigs()
    Dim varItem As Variable
    Dim bExists As Boolean
    Dim iShapeCount As Integer
    Dim iJumpTo As Integer

    ' ensure variable exists
    bExists = False
    For Each varItem In ActiveDocument.Variables
        If varItem.Name = "FigNum" Then
            bExists = True
            Exit For
        End If
    Next varItem

    ' initialize document variable if doesn't exist
    If Not bExists Then
        ActiveDocument.Variables.Add _
          Name:="FigNum", Value:=0
    End If

    ' figure to jump to
    iJumpTo = ActiveDocument.Variables("FigNum") + 1

    ' get number of shapes
    iShapeCount = ActiveDocument.Shapes.Count
    If iJumpTo > iShapeCount Then iJumpTo = 1

    If iShapeCount > 0 Then
        'Display the shape
        ActiveDocument.Shapes(iJumpTo).Anchor.Select
        'Select the shape
        ActiveDocument.Shapes(iJumpTo).Select
    End If
    'Set the variable for next time
    ActiveDocument.Variables("FigNum") = iJumpTo
End Sub

This macro uses a document variable to keep track of which graphic was last selected. If you need to search for floating graphics quite a bit, this means you can assign this macro to the Quick Access Toolbar or a shortcut key and search for each floating graphic in your document, in turn.

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 (10442) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Word here: Searching for Floating Graphics.

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

System Won't Save AutoText

In some instances, Word may actually refuse to save any of your AutoText entries in the Normal.dot template. There are a ...

Discover More

Printing Limited Pages from a Range of Worksheets

Need to print just a few pages from a group of worksheets? The easiest way to handle the task may be through a macro, as ...

Discover More

Making VLOOKUP Trigger a Macro

VLOOKUP is an oft-used worksheet function to lookup values in a data table. If the function cannot return a value, it ...

Discover More

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (ribbon)

Absolutely Positioning a Graphic

Want a graphic to appear at a precise place on the page? It's easy to gain control by following the steps in this tip.

Discover More

Pictures Move on their Own

Insert some pictures into a document and you may be in for a surprise--they don't necessarily stay where you put them. ...

Discover More

Turning Off Borders for Data Series

Don't want a border to appear around a data series represented in a Microsoft Graph chart? You can easily control the ...

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 6 + 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


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.