VBA & Macro Problems

How to Fix Word VBA Photo Insertion Macro Runtime Errors 91 and 4608

Tauseeq MagsiTauseeq Magsi Nov 4, 2026 870 views

Question details

The user needs to fix runtime errors 91 and 4608 that suddenly started occurring in a Word VBA macro used for inserting photos into a table and adding file names.

How to Fix Word VBA Photo Insertion Macro Runtime Errors 91 and 4608
Product
Word
Device & OS
not provided
Scenario
Running a custom VBA macro to automate the insertion of multiple images and their corresponding file names into a Word document table.
Observed behavior
The macro halts execution and displays runtime error 91 or 4608, specifically failing when encountering incorrectly encoded images (like HEVC renamed to JPEG) or when table column variables are not explicitly set.
Before you start

Before debugging your VBA code, identify the exact image file the macro fails on and ensure your Word document is saved to prevent data loss during code testing.

Solution 1Recommended

Identify and Fix Incorrectly Converted Image Formats

Locate and properly convert incompatible image files that cause the macro to crash during the insertion process.

Often, runtime errors during batch image insertion occur when the macro encounters a file with an incorrect extension. For example, an HEVC photo manually renamed to .jpeg without proper format conversion cannot be rendered by Word, triggering an immediate failure in the macro script.

1
Debug the macro

Run your macro as usual. When the runtime error dialog box appears, click the 'Debug' button to open the VBA Editor and see which line of code is highlighted in yellow.

2
Identify the failing image

Hover your mouse over the file name variable in the highlighted code or check the Immediate Window to find out exactly which image file the macro was trying to process when it crashed.

3
Check image encoding

Navigate to the folder containing your source images, locate the problematic file, and try to open it with a standard photo viewer to see if it is corrupted or improperly converted (e.g., an HEVC file posing as a JPEG).

4
Convert the image

Use a dedicated image converter tool or open the file in an image editor and select 'Save As' to properly export it as a standard JPEG file. Rerun the macro.

Identify and Fix Incorrectly Converted Image Formats
Image Compatibility: Ensuring all images are natively saved as standard JPEG or PNG formats before running the macro prevents sudden runtime interruptions.
Advanced Document Automation

Use WPS Writer for Seamless Macro and Image Handling

WPS Office provides robust compatibility with VBA macros, allowing you to automate repetitive tasks like inserting images into tables without hassle. Experience smooth document processing and high compatibility with Word macro-enabled files.

  1. 1. Open your macro-enabled document: Download and install WPS Office, then open your .docm file directly in WPS Writer.
  2. 2. Access developer tools: Navigate to the 'Developer' tab on the top ribbon to access the built-in VBA and Macro tools.
  3. 3. Run your macro: Click 'Macros', select your custom photo insertion script from the list, and click 'Run' to execute it smoothly.
  4. 4. Use native batch insertion (Optional): If you prefer not to use VBA, click 'Insert' > 'Picture' to select and insert multiple images into your document simultaneously with native tools.
Fully compatible with Microsoft Word (.doc, .docx, .docm) formats.Supports VBA macros for advanced document automation and scripting.Lightweight software with fast processing for documents containing large image files.Built-in batch image insertion tools to save time without needing to write code.
microsoft office alternative - wps office

Frequently Asked Questions

What does Runtime Error 91 mean in Word VBA?

Runtime Error 91 indicates 'Object variable or With block variable not set'. It occurs when your macro attempts to use an object (like a specific table or column) that hasn't been properly defined or selected within the code.

Why does an incorrectly converted image cause a macro error?

If an image, such as an HEVC file, is forcibly renamed to .jpg without proper encoding conversion, Word's rendering engine cannot interpret its dimensions or format. When the VBA script tries to insert this unreadable file, the process crashes.

How do I find which line of code is causing the runtime error?

When the runtime error dialog box pops up during macro execution, click the 'Debug' button. The VBA Editor will automatically open and highlight the exact line of code where the macro failed in yellow.