How to count the number of images in a Word document

Counting the number of images in a Word document can be achieved using different methods. Here are two approaches:

Count the Number of Inline Images with Find and Replace Feature:

  1. Click on “Home” > “Find” > “Advanced Find.”
  2. In the “Find and Replace” dialog, go to the “Find” tab.
  3. In the “Find what” box, type ^g and select “Main Document” from the “Find In” drop-down list.
  4. The number of inline images in the Word document will be displayed.

Count the Number of Both Inline Images and Floating Shapes with VBA Code:

Sub CountImages()
Dim shp As Shape
Dim iln As InlineShape
Dim imgCount As Integer

imgCount = 0

‘ Count floating shapes
For Each shp In ActiveDocument.Shapes
imgCount = imgCount + 1
Next shp

‘ Count inline shapes
For Each iln In ActiveDocument.InlineShapes
imgCount = imgCount + 1
Next iln

MsgBox “Total number of images: ” & imgCount
End Sub

To use this VBA code:

  1. Press Alt + F11 to open the “Microsoft Visual Basic for Applications” window.
  2. Insert a new module by clicking on “Insert” > “Module.”
  3. Copy and paste the provided VBA code into the module.
  4. Close the VBA window.
  5. Run the macro by pressing F5.
How to count the number of images in a Word document

How to count the number of images in a Word document

A message box will appear displaying the total number of images (both inline and floating) in the Word document.

Choose the method that best suits your needs, depending on whether you want to count only inline images or both inline images and floating shapes.

Gotkey.net
Logo
Compare items
  • Total (0)
Compare
0
Shopping cart