logo
search
Excel Error Codes

Fix Excel VBA Run-time Error 1004 When Saving as PDF

Maira MehtabMaira Mehtab Sep 28, 2026 868 views

Question details

The user is experiencing a 'Run-time error 1004: Document not saved' in Microsoft Excel when running a VBA macro designed to save a worksheet as a PDF file.

Product
Microsoft Excel
Device & OS
Windows 10
Scenario
Running an existing VBA macro to export or save an Excel worksheet as a PDF to a local or network folder.
Observed behavior
The VBA macro abruptly fails with Error 1004, preventing any PDF from being created, despite working perfectly prior to a recent system or Office update.
Before you start

Ensure that the destination folder specified in your VBA code actually exists, that you have sufficient write permissions for the directory, and that a PDF with the same name is not currently open in another application.

Solution 1Recommended

Open a Support Ticket for Bug Investigation

Since this error often surfaces after specific Windows or Microsoft 365 updates, reporting it via the admin center is the most direct path to an official patch.

When built-in macros suddenly fail across specific devices running identical update builds (like KB5048652), the root cause is frequently a software bug introduced by the update itself. Engaging IT support to open a ticket ensures Microsoft is aware of the capability failure.

1
Access Admin Center

Ask your IT department or Microsoft 365 administrator to log into the Microsoft 365 admin center.

2
Navigate to Support

Click on 'Support' in the left-hand navigation menu, then select 'New service request'.

3
Submit Details

Provide details about the 'Error 1004: Document not saved' issue, mentioning the specific Windows update version (e.g., KB5048652) and the VBA ExportAsFixedFormat method failure.

Workaround: While waiting for a fix, you can manually save worksheets as PDF using File > Save As, or run the macro on a PC that has not yet received the problematic update.
Free Microsoft Office alternative

Switch to WPS Office for Seamless PDF Export

If recurrent Microsoft Excel updates and VBA bugs are disrupting your workflow, consider switching to WPS Office. It provides robust spreadsheet capabilities, high compatibility with Microsoft Office formats, and built-in PDF conversion without the need to troubleshoot macro errors.

  1. 1. Download WPS Office: Visit the official WPS website and download the free WPS Office suite for Windows.
  2. 2. Open Your Workbook: Launch WPS Spreadsheets and open your existing Excel (.xlsx or .xlsm) file seamlessly.
  3. 3. Export to PDF Easily: Go to the Menu and click 'Export to PDF' to save your worksheets instantly, bypassing any need for complex macros.
Highly compatible with Microsoft Excel formats (.xlsx, .xls) and standard VBA scripts.Built-in, one-click export to PDF feature that is stable and free to use.Lightweight software with a familiar user interface for immediate productivity.Cost-effective and free alternative to expensive Microsoft 365 subscriptions.
microsoft office alternative - wps office

Frequently Asked Questions

Why does VBA Error 1004 happen only on one computer?

Differences in background Windows updates (such as KB5048652), Office version builds, or local folder permissions can cause identical VBA code to fail on one machine while it continues to work flawlessly on another.

Can I roll back the Windows update to fix the VBA PDF error?

Yes, if a specific Windows update caused the PDF export failure, you can temporarily uninstall it by going to Settings > Update & Security > Windows Update > View update history > Uninstall updates, then rebooting your PC.

How do I save as PDF manually if the Excel macro fails?

You can easily bypass the VBA error by navigating to File > Save As, selecting PDF from the file format dropdown menu, and clicking Save. Alternatively, you can use File > Export > Create PDF/XPS Document.