How to Fix Excel for Mac Error 1004 When Saving a CSV via VBA
Question details
The user is encountering Runtime Error 1004 ('Cannot access read-only document') when attempting to save a CSV file to the Mac Desktop using a VBA macro.

- Product
- Microsoft Excel
- Device & OS
- macOS
- Scenario
- Executing a VBA SaveAs script to export or save a CSV document to the user's Desktop directory.
- Observed behavior
- Excel displays an error prompt stating the document is read-only and fails to save the file, typically caused by an incomplete directory path or sandboxing restrictions on Mac.
Verify that your Mac's System Settings allow Excel to access the Desktop folder, and ensure that the target CSV file is not currently open in another application.
Define the Complete File Path in Your VBA Code
Correcting the file path syntax ensures Excel knows exactly where to save the file and what to name it, preventing read-only access errors.
In Excel for Mac, VBA requires a highly specific and complete file path to execute the SaveAs command successfully. If the filename or extension is omitted from the directory string, Excel misinterprets the path as a read-only directory.
In your VBA editor, set your filepath variable to include the full directory and the filename. For example: `FilePath = "/Users/myusername/Desktop/MYCSVTEST.csv"`.
Pass the complete string to the SaveAs command. Ensure you specify the correct file format using `FileFormat:=xlCSV`.
Add `CreateBackup:=False` to your SaveAs line. This prevents Excel from attempting to write an additional backup file, which can trigger separate permission errors on macOS.

Grant Excel macOS Permissions to Access the Desktop
macOS security settings may block Excel from saving files to specific folders like the Desktop unless explicitly permitted.
Experience a Seamless and Error-Free Spreadsheet Alternative
Tired of dealing with complex VBA runtime errors and macOS permission issues? WPS Office offers a free, lightweight, and highly compatible alternative to Microsoft Office, ensuring your spreadsheet tasks are completed smoothly without complicated configurations.
- 1. Download the Mac installer: Visit the official WPS website and download the free WPS Office installer designed specifically for macOS.
- 2. Install WPS Office: Open the downloaded file and follow the simple on-screen instructions to install the application.
- 3. Open and save your CSV files: Launch WPS Spreadsheet and easily open, edit, and save your CSV files directly to your Desktop without worrying about VBA macro errors.

Frequently Asked Questions
Why does Excel for Mac say my CSV is read-only when using VBA?
This usually happens if the VBA SaveAs path is incomplete (such as missing the filename or the .csv extension), or if macOS sandboxing is actively preventing Excel from writing data to your Desktop folder.
How do I find the correct username for my Mac file path?
Open a Finder window, go to your 'Users' folder on your Macintosh HD, and look for the folder with the home icon. The name of that folder is the exact username you need to use in your VBA `"/Users/yourusername/Desktop/"` file path.
Does WPS Office support saving CSV files?
Yes, WPS Spreadsheet fully supports reading, editing, and saving CSV files seamlessly on both Mac and Windows devices, maintaining excellent format compatibility with Microsoft Excel.




