Others

How to Use a Word Macro to Save Figures and Captions as Separate Files

Bushra ParveenBushra Parveen Nov 2, 2026 869 views

Question details

The user needs a way to automatically extract all inline images and their associated captions from a Word document and save each pair as an independent file.

How to Use a Word Macro to Save Figures and Captions as Separate Files
Product
Microsoft Word
Device & OS
not provided
Scenario
Extracting multiple figures and captions into individual files for easier management, archiving, or publishing.
Observed behavior
The user has a single document containing multiple figures with captions and requires an automated VBA solution to split them into separate documents.
Before you start

Ensure you have the Developer tab enabled in your Word ribbon, as you will need access to the Visual Basic Editor to insert and run the macro script.

Solution 1Recommended

Use a VBA Macro to Extract Figures and Captions

Create and run a VBA macro that searches for the Caption style, identifies the related inline image, and saves them together in a new document.

This solution uses a custom VBA script to automate the extraction process. The macro looks for paragraphs formatted with the 'Caption' style, locates the preceding inline shape (the figure), and copies both into a new document.

The new documents are saved in an automatically generated subfolder within the same directory as your original file, named according to the figure's label (e.g., Fig1.docx).

1
Open the VBA Editor

Press 'Alt + F11' in Microsoft Word to open the Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the Project Explorer pane on the left, right-click your document's name, select 'Insert', and choose 'Module'.

3
Paste the Macro Code

Paste your VBA code designed to search for the 'Caption' style and copy the preceding inline shape into the empty module window.

4
Run the Macro

Close the VBA editor or press 'F5' while inside the module to run the macro. The script will create a subfolder and generate the separate Word files for each figure.

Use a VBA Macro to Extract Figures and Captions
Important Document Format Requirement: This macro specifically targets 'Inline' figures and paragraphs using the exact 'Caption' style. If your images are set to 'Square' or 'Tight' text wrapping, the macro may fail to locate them.
Free Microsoft Office alternative

Try WPS Office for Your Document Processing Needs

While running complex VBA macros often requires specific Microsoft Word configurations, WPS Office provides a lightweight, highly compatible alternative for handling complex document layouts, image insertions, and daily word processing tasks without the heavy subscription fees.

Fully compatible with Microsoft Word formats (.docx, .doc).Intuitive interface for managing images, captions, and text wrapping.Free to use with a lightweight installation package.Built-in PDF conversion and advanced editing tools.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my VBA macro not finding the figures in my document?

The macro relies on specific formatting to locate figures. Ensure your images are inserted as 'In Line with Text' rather than floating, and that the text below them is strictly formatted using Word's built-in 'Caption' style.

Can I save the extracted figures as image files instead of Word documents?

Yes, but it requires a modified VBA script. The macro provided in this solution creates separate .docx files containing both the image and the text. To export as standalone image files (like PNG or JPEG), you would need to use the 'SaveAsPicture' method in VBA.

Where does the macro save the new separate figure files?

The macro creates a new subfolder in the exact same directory where your original source document is saved. It names the individual files based on the text appearing before the colon in the caption, such as 'Fig1.docx'.

How do I correctly apply the 'Caption' style to my text?

Select the text below your image, navigate to the 'Home' tab, and click on 'Caption' in the Styles pane. Alternatively, right-click the image and select 'Insert Caption' to automatically generate properly formatted caption text.