
Tips.Net > WordTips Home > Graphics > Searching for Graphics > Searching for Floating Graphics
Summary: Graphics can be added to a document so that they are either inline with the text or floating over the text. You can use Word’s find and replace tool to locate the inline graphics, but not the floating ones. This tip provides ways you can find the latter. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
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 VBA, 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 a toolbar button or a shortcut key and search for each floating graphic in your document, in turn.
Tip #1771 applies to Microsoft Word versions: 97 2000 2002 2003
Create and Merge! Using Word's mail merge tool you can quickly and easily combine data from a variety of data sources to create great individualized documents that incorporate your data in ways that you control. WordTips: Mail Merge Magic is an invaluable source for learning how to harness the full power of Word's mail merging capabilities.
Check out WordTips: Mail Merge Magic today!
Do you want a decade of WordTips information at your fingertips? You can find what you need with the WordTips Ten-Year Library. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips