Excel Error Codes

Fix Excel 2016 for Mac VBA Error 1004 When Exporting a Range to PDF

John WilsonJohn Wilson Nov 25, 2026 870 views

Question details

The user needs to resolve VBA Runtime Error 1004 when exporting an Excel worksheet range to PDF.

Fix Excel 2016 for Mac VBA Error 1004 When Exporting a Range to PDF
Product
Microsoft Excel 2016 for Mac
Device & OS
Mac
Scenario
A VBA procedure exports a worksheet range containing calculated results as a PDF.
Observed behavior
The PDF export procedure raises Runtime Error 1004.
Before you start

Identify the line that raises Error 1004 and note the target worksheet, range, and PDF output path. Check that the destination folder exists and that you can save a file there from Excel.

Solution 1Recommended

Check the VBA range and PDF output path

Use these checks to rule out an invalid range, filename, or destination before investigating Excel compatibility issues.

1
Locate the failing line

Open the VBA editor from Tools > Macro > Visual Basic Editor, run the procedure, and select Debug when the error appears. Note the highlighted export statement.

2
Verify the range

In the export code, check that the workbook and worksheet references point to the intended sheet and that the range address contains the cells you want to export.

3
Test the destination

Use File > Save As to test saving a file to the intended folder. In the VBA export statement, use an existing writable folder and a simple PDF filename without path separators, such as results.pdf.

4
Test a Mac-specific export procedure

Review the range's ExportAsFixedFormat call and test a Mac-specific example with a small range and the verified output path. Run the procedure again from the VBA editor.

Check the VBA range and PDF output path
Compatibility can still affect export: Excel 2016 for Mac had known VBA and PDF-export compatibility issues. A valid range and writable path do not guarantee that every export procedure will work.
Free Microsoft Office alternative

Work with spreadsheets and PDFs in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for opening spreadsheets and creating PDFs. Its Microsoft Office format compatibility can help you move existing files, though it does not fix Excel's VBA error and complex macros may need separate testing.

Export spreadsheet content to PDF without relying on Excel's PDF export procedureOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface for everyday workMove existing Office documents into a free, lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

What causes Error 1004 during a PDF export?

The error can result from an invalid range, an unsupported filename, an inaccessible destination, or an Excel for Mac compatibility issue. Select Debug in the error dialog to identify the failing VBA statement.

How can I check whether Excel can write to the PDF folder?

Choose File > Save As and try saving a file in the same folder. If that fails, select an existing folder where your Mac user account has permission to write, then update the VBA output path.

Can I export just the range without running the macro?

Yes. Select the cells, choose Page Layout > Print Area > Set Print Area, then use File > Print and the PDF menu to save the selection as a PDF.

Will WPS Office fix the VBA error in Excel?

No. WPS Office is a separate alternative for working with spreadsheets and PDFs; it does not repair Excel's VBA export. Test any complex macros separately before relying on them in another application.