logo
search
Office Settings & Configuration

How to Fix Word VBA Errors When Exporting Image and Table Alt Text

Maira MehtabMaira Mehtab Sep 22, 2026 869 views

Question details

Users experience a VBA error in Microsoft Word when running a macro to export image and table alternative text into a new document.

Product
Microsoft Word
Device & OS
not provided
Scenario
Running a VBA macro to extract and export alternative text from images and tables to a separate, newly created Word document.
Observed behavior
The VBA macro fails and throws an error at the docTranslate.Save command because the newly created document does not yet have a defined file path or filename.
Before you start

Before modifying your VBA code, ensure you have a backup of your original macro text and verify that the destination folder where you intend to save the exported document actually exists on your system.

Solution 1Recommended

Replace the Save Method with SaveAs in Your VBA Macro

Modify the VBA script to use the SaveAs method, which properly assigns a file name and directory path to the newly created document before attempting to save it.

When a macro creates a completely new document, that document only exists in the application's memory. Calling the standard Save method causes an error because there is no existing file path to overwrite.

By switching to the SaveAs method, you can dynamically define the new filename and path based on your original document's properties.

1
Open the VBA Editor

In Microsoft Word, press ALT + F11 on your keyboard to launch the Visual Basic for Applications (VBA) editor.

2
Locate the Export Macro

In the Project Explorer pane on the left, find the module containing your Alt Text export macro and double-click to open the code.

3
Find the Save Command

Scroll through your code to locate the exact line that reads: docTranslate.Save

4
Update to SaveAs

Replace the docTranslate.Save line with the following code: docTranslate.SaveAs FileName:=Replace(strPictures,".doc"," Alt Text.doc")

5
Run and Test the Macro

Press F5 or click the Run button to execute the modified macro. The newly generated document containing the alternative text should now save successfully without triggering an error.

Variable Dependencies: Ensure that the strPictures variable in the provided code snippet accurately holds the full file path of your original document, as the Replace function relies on it to name the new file.
Free Microsoft Office alternative

Looking for a Seamless Alternative to Microsoft Word?

If you frequently encounter complex macro errors or need a more straightforward document processing experience, consider switching to WPS Office. It provides a lightweight, highly compatible environment for all your document needs.

  1. 1. Download and Install: Visit the official WPS Office website to download the free installer and follow the on-screen instructions to set it up.
  2. 2. Open Your Documents: Launch WPS Writer and go to Menu > Open to select your existing Word files.
  3. 3. Edit Seamlessly: Begin editing your text, images, and tables immediately with full format retention and compatibility.
Highly compatible with Microsoft Word (.docx, .doc, .dotm) formatsLightweight application that installs quickly and uses minimal system resourcesFamiliar tabbed user interface for a zero-learning-curve migrationPowerful built-in tools for formatting images, tables, and alternative text
microsoft office alternative - wps office

Frequently Asked Questions

Why does the Save method fail on a newly created document in VBA?

The standard Save method requires a file to already exist on your hard drive. Because a newly created document only exists in memory and lacks a defined file path and filename, calling Save results in an error. You must use SaveAs for the initial save.

What does the Replace function do in this VBA solution?

The Replace function takes the original filename string, finds the '.doc' extension, and swaps it with ' Alt Text.doc'. This automatically generates a logical, distinct filename for your exported text document in the same directory.

How do I ensure my VBA macro saves the document in the correct folder?

The SaveAs method relies on the full file path provided to it. As long as the variable used (like strPictures) contains the absolute path (e.g., C:\Documents\file.doc), the new file will be saved in that exact same directory.