Suppose you have created a Word document that contains both text and images, and to easily navigate between these images, adding captions to all of them would be a good choice. The most common way is to select each image and insert a bookmark using the Bookmark function in Word. However, it can be time-consuming if you need to deal with many images. Here, we provide two methods for you to automatically add captions to all images at once in a Word document.
Automatically add captions to images at once using VBA:
The VBA code below can help add captions to all images at once in a Word document. Here’s how:
- Open the Word document containing the images you want to add captions to, press the Alt + F11 key combination to open the Microsoft Visual Basic for Application window.
-
In the Microsoft Visual Basic for Application window, click Insert > Module. Then copy the VBA code below into the Module window.
‘Updated by Extendoffice 20181123
Dim xPic As InlineShape
For Each xPic In ActiveDocument.InlineShapes
xPic.Select
Selection.InsertCaption “Figure”, “”, “”, wdCaptionPositionBelow, 0
Next
End Sub
- Press the F5 key to run the code.
Now, captions will be added to all images in the current document at once as shown in the screenshot below.