Fix Excel 2016 for Mac VBA Error 1004 When Exporting a Range to PDF
Question details
The user needs to resolve VBA Runtime Error 1004 when exporting an Excel worksheet 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.
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.
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.
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.
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.
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.
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.

Update Excel and report a reproducible error
Use this approach if the range and destination are valid but the VBA export still fails.
Save the selected range as a PDF manually
Use this workaround when you need a PDF now and do not need the export to run automatically.
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.

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.




