logo
search
VBA & Macro Problems

Fix Excel VBA Run-Time Error 53 When Attaching Temporary Files to Email

Amos GikundaAmos Gikunda Oct 1, 2026 869 views

Question details

The user needs to resolve run-time error 53 that prevents a VBA macro from attaching a newly created temporary workbook to an Outlook email.

How to Fix Excel VBA Run-Time Error 53 When Attaching Temporary Files
Product
Microsoft Excel
Device & OS
not provided
Scenario
Executing a VBA macro that saves visible Excel cells to a temporary file and attempts to attach it to an Outlook email message.
Observed behavior
After updating to Excel version 2402, the macro fails with run-time error 53 because the system cannot find the temporary file during the email attachment process.
Before you start

Before modifying your VBA script, ensure you have backed up your original macro-enabled workbook and verify that your system's temporary folder path has proper write permissions.

Solution 1Recommended

Check file path timing and consistency

Use this solution to address timing issues where the VBA script tries to attach the file before the operating system has finished saving it.

Software updates can sometimes alter how quickly Excel processes file saving operations. If the macro attempts to attach the file before the OS has fully written it to the disk, run-time error 53 (File not found) occurs.

1
Add a DoEvents command

In your VBA Editor, insert the command 'DoEvents' immediately after your 'SaveAs' line. This forces the script to yield execution so the operating system can finish creating the temporary file before moving to the attachment step.

2
Verify the exact file path

Use 'Debug.Print' to output the exact string variable containing your temporary file path to the Immediate Window (Ctrl+G). Verify that the path string precisely matches the location where the file is being saved.

3
Implement a brief pause

If DoEvents is insufficient, use 'Application.Wait (Now + TimeValue("0:00:02"))' to add a 2-second delay before the '.Attachments.Add' line executes.

Check file path timing and consistency
Timing resolved: Allowing the system a few moments to write the file usually prevents the 'File not found' error during attachment.
Free Microsoft Office alternative

Try WPS Office for Stable Spreadsheet Management

If frequent updates in Microsoft Office disrupt your workflows and script executions, consider switching to WPS Office. It provides a highly compatible environment for handling complex spreadsheets and daily tasks seamlessly, without disruptive background updates.

  1. 1. Download the installer: Visit the official WPS Office website and click the Free Download button.
  2. 2. Install the software: Run the downloaded setup file and follow the on-screen instructions to complete the installation.
  3. 3. Open your spreadsheets: Launch WPS Spreadsheets and open your existing Excel workbooks to continue your work without interruption.
Highly compatible with Microsoft Excel (.xlsx, .xls, .xlsm, .csv) formats.Stable performance that minimizes disruptive background updates breaking workflows.Lightweight design that runs smoothly on both older and newer devices.Familiar user interface requiring zero learning curve for Excel users.
microsoft office alternative - wps office

Frequently Asked Questions

What does Run-time error 53 mean in Excel VBA?

Run-time error 53 indicates 'File not found'. In VBA, this happens when a script attempts to access, open, or attach a file that does not exist at the specified path, or has not finished saving to the disk yet.

Why did my VBA email attachment macro stop working after Excel update 2402?

Office updates can sometimes alter how quickly Excel processes file saving operations or handles temporary directories. If the macro tries to attach the file before the operating system has fully written it to the disk, it triggers an error.

How do I find the temporary file path my VBA macro is using?

You can find the temporary file path by inserting 'Debug.Print Environ("Temp")' or outputting the specific string variable used in your SaveAs method into the Immediate Window (accessed by pressing Ctrl+G) in the VBA Editor.

Can I roll back my Excel version to fix the VBA macro error?

Yes, you can temporarily roll back your Microsoft 365 installation to a previous version using the Office Deployment Tool. However, it is generally safer and more sustainable to adjust your VBA code to handle the new timing or file path requirements.