Excel Error Codes

How to Fix Excel for Mac Error 1004 When Saving a CSV via VBA

Olivia MillerOlivia Miller Nov 3, 2026 869 views

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.

How to Fix Excel for Mac Error 1004 When Saving a CSV via VBA
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.
Before you start

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.

Solution 1Recommended

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.

1
Construct the exact file path

In your VBA editor, set your filepath variable to include the full directory and the filename. For example: `FilePath = "/Users/myusername/Desktop/MYCSVTEST.csv"`.

2
Configure the SaveAs parameters

Pass the complete string to the SaveAs command. Ensure you specify the correct file format using `FileFormat:=xlCSV`.

3
Disable the backup creation

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.

Define the Complete File Path in Your VBA Code
Path formatting tip: Always double-check that your Mac username is spelled correctly in the string and that the path ends with the actual '.csv' extension.
Free Microsoft Office alternative

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. 1. Download the Mac installer: Visit the official WPS website and download the free WPS Office installer designed specifically for macOS.
  2. 2. Install WPS Office: Open the downloaded file and follow the simple on-screen instructions to install the application.
  3. 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.
100% compatible with Microsoft Excel file formats, including .xlsx and .csv.Lightweight application that runs smoothly on Mac, Windows, and Linux.Intuitive interface with powerful built-in spreadsheet functions.Completely free to use for everyday document, spreadsheet, and presentation tasks.
microsoft office alternative - wps office

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.