Fix Excel VBA ExportAsFixedFormat PDF Error on Mac & SharePoint
Question details
The user is unable to generate PDF files using the Excel VBA ExportAsFixedFormat method when iterating through dropdowns, specifically when the workbook is stored on SharePoint or OneDrive for Mac.

- Product
- Microsoft Excel
- Device & OS
- Mac
- Scenario
- Running a VBA macro to automatically generate and export multiple PDFs based on dropdown list selections to a cloud-synced folder.
- Observed behavior
- The macro fails to execute or export the PDFs, typically returning a path error due to invalid SharePoint web URLs, missing local folders, or attempting to run the code in Excel for the Web.
Ensure your OneDrive or SharePoint folders are fully synchronized and mounted locally on your Mac, as Excel VBA cannot save directly to a web URL using standard local file system commands.
Update VBA Code for Mac OneDrive Local Sync Paths
Use the correct local file path format for CloudStorage on Mac to allow the VBA macro to locate and save to the directory.
On Mac, OneDrive and SharePoint synced folders do not use standard Windows drive letters (like C:\) or web URLs. Instead, they reside in the local Library folder under CloudStorage.
Open Finder, navigate to your OneDrive or SharePoint synced folder, right-click the target output folder, hold the 'Option' key, and select 'Copy as Pathname'.
Assign the copied local path to your PDFPath variable in the VBA editor (e.g., PDFPath = "/Users/yourname/Library/CloudStorage/OneDrive-Company/").
Use the Dir function in your VBA code to verify the folder exists before executing ExportAsFixedFormat, for example: If Dir(PDFPath, vbDirectory) = "" Then MsgBox "Folder not found".
Add 'Debug.Print FullPath' before the export command to print the exact save destination in the Immediate Window, ensuring the path and filename are formatted correctly.

Run the Workbook in the Desktop Application
VBA macros are not supported in Excel for the Web or directly inside a SharePoint browser view.
Pre-Create the Destination Folder
The ExportAsFixedFormat method will instantly fail if the target directory does not already exist on your machine.
Export to PDF Easily with WPS Office
Avoid complex VBA debugging on Mac and SharePoint. WPS Office is a free, lightweight alternative to Microsoft Office that offers seamless compatibility with Excel files and features a highly reliable, built-in PDF converter that works perfectly across different operating systems.
- 1. Open your workbook: Launch WPS Spreadsheets and open your .xlsx or .xlsm file.
- 2. Access the Export feature: Navigate to the 'Menu' or 'Tools' tab on the ribbon and select 'Export to PDF'.
- 3. Save your PDF: Choose your preferred local or synced cloud folder and click 'Export'.

Frequently Asked Questions
Can I run Excel VBA macros in SharePoint online or Excel for the Web?
No, VBA macros cannot run in the browser version of Excel. You must open the workbook in the desktop application to run ExportAsFixedFormat. For web-based automation, consider using Office Scripts or Microsoft Power Automate.
Why do I get a 'Path not found' error on Mac when saving to OneDrive?
Mac uses a different file path structure than Windows. Instead of URLs or standard drive letters like C:\, OneDrive paths on Mac typically look like /Users/YourUsername/Library/CloudStorage/OneDrive-YourCompany/.
Will ExportAsFixedFormat automatically create a new folder if it is missing?
No, Excel will not automatically create missing folders during the PDF export process. You must ensure the folder exists manually or include VBA code (such as the MkDir command) to create it before exporting.
How can I verify where Excel is trying to save my PDF?
You can add the command 'Debug.Print FullPath' in your VBA code just before the ExportAsFixedFormat line. This will print the exact save destination in the Immediate Window (press Ctrl+G in the VBA editor to view it).




