Skip to main content

How to count the number of images in a Word document?

Author: Xiaoyang Last Modified: 2024-07-17

Counting the number of images in a Word document can be useful for various purposes, such as quality control, compliance with guidelines, or simply for organizational reasons. Manually counting images in a lengthy document can be tedious and error-prone. Fortunately, there are efficient methods to quickly and accurately count the number of images in a Word document.

In this tutorial, we will guide you through the steps to easily count the number of images, helping you manage your document more effectively.

Count the number of inline images with Find and Replace feature

Count the number of both inline images and floating shapes with VBA code


Office Tab: Brings tabbed interfaces to Word, Excel, PowerPoint...
ot word middle ad 100
Enhance your workflow now.      Learn More about Office Tab       Free Download

Count the number of inline images with Find and Replace feature

The Find and Replace feature in Word can help you to count the number of inline pictures only quickly and easily, please do as follows:

1. Click Home > Find > Advanced Find, see screenshot:

Advanced Find on the Ribbon

2. In the Find and Replace dialog box, under the Find tab, type the ^g into the Find what text box, and then choose Main Document from the Find In drop down list, see screenshot:

Find and Replace dialog 1

3. And then you can see the number of the inline images in this Word document has been displayed as following screenshot shown:

Find and Replace dialog 2


Count the number of both inline images and floating shapes with VBA code

The above method can only count the number of inline images, if there are some floating shapes in the document, they will not be counted. The following VBA code can help you to count both the inline images and floating shapes, please do as this:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Then, click Insert > Module, copy and paste below code into the opened blank module, see screenshot:

VBA code: Count the number of both inline images and floating shapes:

Sub CountImagesInDoc()
    Dim xInlines As Long
    Dim xFloaters As Long
    Dim sh As Shape
    Dim tbxs As Long
    Dim msg As String
    With ActiveDocument
        For Each sh In .Shapes
            If sh.Type = msoTextBox Then tbxs = tbxs + 1
        Next
        xInlines = .InlineShapes.Count
        xFloaters = .Shapes.Count - tbxs
    End With
    xPrompt = "Inline images:" & vbTab & xInlines & vbCr
    xPrompt = xPrompt & "Floating shapes:" & vbTab & xFloaters & vbCr
    xPrompt = xPrompt & vbTab & "Total:" & vbTab & (xInlines + xFloaters) & vbCr
    xPrompt = xPrompt & "Counts do not include headers and footers, etc."
    MsgBox xPrompt, vbInformation, "Kutools for Word"
End Sub

3. After pasting the code, then press F5 key to run this code, and a prompt box is popped out to tell you how many inline images and floating shapes in this Word document, see screenshot:

Success notification popup


Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

πŸ€– Kutools AI Assistant: Transform your writing with AI - Generate Content  /  Rewrite Text  /  Summarize Documents  /  Get Quick Answers, all within Word

πŸ“˜ Document Mastery: Split Pages  /  Merge Documents  /  Export Selection in Various Formats (PDF/TXT/DOC/HTML...)  /  Batch Convert to PDF  /  Export Pages as Images  /  Print Multiple Files at once...

✏ Contents Editing: Batch Find and Replace across Multiple Files  /  Resize All Pictures  /  Transpose Table Rows and Columns  /  Convert Table to Text...

🧹 Effortless Clean: Sweap away Extra Spaces  /  Section Breaks  /  All Headers  /  Text Boxes  /  Hyperlinks  /  For more removing tools, head to the Remove group...

βž• Creative Inserts: Insert Thousand Separators  /  Check Boxes  /  Radio Buttons  /  QR Code  /  Barcode  /  Diagonal Line Table  /  Equation Caption  /  Image Caption  /  Table Caption  /  Multiple Pictures  /  Discover more in the Insert group...

πŸ” Precision Selections: Pinpoint Specific Pages  /  Tables  /  Shapes  /  Heading Paragraphs  /  Enhance navigation with more Select features...

⭐ Star Enhancements: Navigate to Any Location  /  Auto-Insert Repetitive Text  /  Toggle Between Document Windows  /  11 Conversion Tools...

Kutools and Kutools Plus tabs on the Word Ribbon
πŸ‘‰ Want to try these features? Download Kutools for Word now! πŸš€
 
Comments (1)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
helpfulllllπŸ˜€πŸ˜
Rated 5 out of 5
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations