Fix Excel VBA Run-Time Error 53 When Attaching Temporary Files to Email
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.

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

Consult developer forums with a reproducible example
When a specific version update (like 2402) breaks a previously working macro, community developer forums are the best resource for identifying version-specific bugs.
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. Download the installer: Visit the official WPS Office website and click the Free Download button.
- 2. Install the software: Run the downloaded setup file and follow the on-screen instructions to complete the installation.
- 3. Open your spreadsheets: Launch WPS Spreadsheets and open your existing Excel workbooks to continue your work without interruption.

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.




