Excel VBA on Mac: How to Open Files with a Macro

VBA & macros · Updated November 19, 2026

Yes. Excel for Mac can open a workbook from VBA with Workbooks.Open; give it the file’s full Mac path, such as /Users/yourname/Documents/Report.xlsx. For a person to choose the file instead, use Application.GetOpenFilename and pass the selected path to Workbooks.Open.

How opening a file with VBA works

VBA tells Excel which workbook to open. The key method is Workbooks.Open, and its Filename argument identifies the workbook. The method returns a Workbook object, which you can store in a variable if the macro needs to refer to the newly opened file later.

The workbook being opened does not have to be the workbook that contains the macro. For example, a macro in a control workbook can open a monthly report, read its data, and leave it open. A file opened this way appears in Excel like a workbook opened through File > Open, though the macro can also set options such as whether to open it read-only.

Before running any macro that changes or processes files, save a copy of important workbooks. VBA actions cannot be reversed with Ctrl+Z, and opening a file alone does not make later changes to it reversible.

Use a full Mac file path

On a Mac, a common full path begins with /Users/. For example, a workbook in a user’s Documents folder might be at /Users/Alex/Documents/Quarterly Report.xlsx. Replace the example user name and file name with the actual ones on the Mac. Spaces in folder or file names are fine when the entire path is enclosed in VBA quotation marks.

Other common locations have different paths. A file on an external drive may be under /Volumes/DriveName/, while a file in a synced cloud folder may be inside a folder associated with that service. A path copied from Finder can help identify the location, but confirm that it points to the actual file and not a shortcut or an online-only placeholder.

  • Use a full path when the macro should always open one known file.
  • Prefer a file picker when different users have different account names, folder layouts, or file names.
  • Use a stable shared location for a team process; a path tied to one person’s home folder will not usually work for everyone.

Windows paths such as C:\Reports\Report.xlsx are not Mac paths. If a workbook must run on both platforms, the macro needs to account for the operating system and the different locations. Do not assume that a path that works on one computer will resolve on the other.

Open a known workbook by path

This example opens one workbook from a fixed location. Change the path before using it. It includes basic error handling so Excel can show a useful message if the path is wrong, access is denied, or the file cannot be opened.

Sub OpenWorkbookOnMac()
    Dim filePath As String
    Dim openedBook As Workbook

    ' Replace this example with the workbook's full Mac path.
    filePath = "/Users/yourname/Documents/Monthly Report.xlsx"

    On Error GoTo OpenError
    Set openedBook = Workbooks.Open(Filename:=filePath)
    Exit Sub

OpenError:
    MsgBox "Excel could not open the workbook: " & Err.Description, vbExclamation
End Sub

The openedBook variable refers to the workbook that Excel opened. If later code needs to work with its first worksheet, for example, it can refer to openedBook.Worksheets(1). That is more explicit than relying on whichever workbook happens to be active. The example does not save changes or close the opened workbook; add those actions only if they are appropriate for the task.

The macro should be stored in a macro-enabled workbook, normally an .xlsm file, or in another suitable VBA host such as an add-in. A regular .xlsx workbook cannot store VBA code. The file being opened can be an ordinary .xlsx workbook if it does not itself need to contain macros.

Let the user choose a file

A picker is usually more practical than hard-coding a personal path. Application.GetOpenFilename displays Excel’s file-selection dialog and returns the chosen file name, or the Boolean value False if the user cancels. The variable must be a Variant because the return value can be either text or Boolean.

Sub ChooseAndOpenWorkbookOnMac()
    Dim selectedPath As Variant
    Dim openedBook As Workbook

    ' Show Excel's file picker; do nothing if the user cancels.
    selectedPath = Application.GetOpenFilename
    If selectedPath = False Then Exit Sub

    On Error GoTo OpenError
    Set openedBook = Workbooks.Open(Filename:=CStr(selectedPath))
    Exit Sub

OpenError:
    MsgBox "Excel could not open the selected file: " & Err.Description, vbExclamation
End Sub

This method avoids assuming that every user stores the workbook in the same folder. The picker itself does not open the workbook; it only supplies a path. The call to Workbooks.Open performs the opening. If the user cancels, the macro exits without trying to open anything.

Do not assume that a file picker is a security check. A user can select a file that contains unsafe macros or unexpected data. If you use optional arguments to limit file types, treat that as a convenience for choosing, not as proof that a file is trustworthy.

Choose how Excel opens the workbook

Workbooks.Open accepts optional arguments that control common opening behavior. Use only the options your process needs, and be particularly careful with external links and files from other people.

  • ReadOnly:=True opens the workbook without intending to edit the source file. This is useful for a report that the macro only reads.
  • UpdateLinks:=0 tells Excel not to update external references as it opens the workbook. This can avoid refreshing links to other files, but linked values may then remain at their last saved state.
  • ReadOnly:=False requests a normal editable opening, subject to file permissions and whether another user or process has the file locked.

For instance, to open a selected workbook read-only and not update external links, include both named arguments in the call to Workbooks.Open. Named arguments make the choice clearer than relying on the position of optional parameters. Opening read-only is not the same as making a separate copy: edits made in Excel may still be possible in memory, but saving over the original is restricted.

If a workbook is password-protected, Excel may ask for the password. Avoid putting a real password directly into macro code: anyone who can inspect the VBA project may be able to find it. For sensitive files, follow the organization’s approved credential and file-access procedures rather than embedding secrets in a macro.

Mac-specific behavior and permissions

Excel for Mac supports VBA, but the surrounding operating system and Excel’s privacy protections can affect access to files. When a macro first tries to open a file in a protected location, macOS or Office may require the user to grant access. If the macro fails despite a path that looks correct, try opening the file through Excel’s dialog or Finder and respond to any permission prompt. The exact prompt can depend on the Office and macOS versions and the file’s location.

Cloud-synced folders introduce another practical issue: the file may not be downloaded locally, or its local path may differ between users. Confirm that it is available on the Mac and test the macro with the same account and folder arrangement that will be used in normal operation. An external drive must be mounted, and its volume name must match the path.

Excel’s VBA editor and menu labels can vary somewhat by release, but the basic VBA method is still Workbooks.Open. On Mac, open the Visual Basic Editor from Excel’s Developer tab or through Tools > Macro > Visual Basic Editor, depending on the version and ribbon setup. If the Developer tab is hidden, enable it in Excel’s ribbon preferences. You may also use the Mac keyboard shortcut Option+F11 in versions that support it; some Mac keyboards require the Fn key with function-key shortcuts.

Common problems and how to diagnose them

When an open macro fails, first separate a path problem from a permissions or file problem. Try opening the same file manually in Excel. If manual opening fails too, VBA is unlikely to be the root cause. If manual opening works, compare the exact path used in the macro with the file’s current location and name.

  • File not found: Check spelling, extension, spaces, and every folder in the path. A renamed file or a changed cloud-sync location makes a hard-coded path stale.
  • Permission denied: Check macOS access prompts, file permissions, and whether the workbook is open or locked elsewhere. Try selecting the file through Excel to see whether access is granted.
  • Picker appears but nothing opens: Confirm that the code continues from the picker to Workbooks.Open, and that cancellation is handled before converting the result to text.
  • External links prompt or show old values: Decide whether the workbook should refresh links. Setting UpdateLinks:=0 suppresses their update; it does not repair broken links.
  • Macro does not run: Check that the code is in a VBA-enabled file and that Excel’s macro security settings allow the macro to run. Do not enable macros in an unfamiliar workbook just to make it open.

For diagnosis, temporarily use a simple path to a small local workbook that you can open manually. Once that works, add the real folder, optional arguments, and any later processing one piece at a time. Avoid suppressing all errors with On Error Resume Next; it can make a failed open look like a successful run.

Safety and good macro design

Opening a workbook is not automatically dangerous, but a macro can go on to change data, run code, or overwrite files. Only run VBA from a source you trust, and keep a backup before testing code that modifies workbooks. Excel’s macro security settings and macOS access controls serve different purposes: allowing a macro to run does not mean every file operation is automatically safe or permitted.

For dependable automation, keep file selection and file processing distinct. First confirm that the user selected a file; then open it; then refer to the returned Workbook variable rather than depending on the active workbook. Decide in advance whether the source should be read-only, whether external links should update, and what should happen if the file is already open or cannot be accessed.

Avoid automatically saving over an input workbook unless that is an explicit requirement. If the macro produces a transformed result, saving a new output file is often safer than replacing the source. Since VBA changes cannot be undone with Ctrl+Z, a separate output and a retained original provide a straightforward recovery path.

Frequently Asked Questions

Can Excel VBA open files on a Mac?

Yes. Excel for Mac supports VBA and the Workbooks.Open method. Use a valid path accessible to that Mac, or let the user choose the file with Application.GetOpenFilename.

What path format should I use in Mac Excel VBA?

Use the Mac file path, commonly a POSIX-style path such as /Users/yourname/Documents/Report.xlsx. A Windows path beginning with a drive letter, such as C:\, will not identify the corresponding Mac file.

How do I open a file picker from VBA on a Mac?

Call Application.GetOpenFilename, check whether its result is False, and pass the selected path to Workbooks.Open. The picker selects a file; it does not open it by itself.

Can VBA open a workbook read-only?

Yes. Pass ReadOnly:=True to Workbooks.Open. This is appropriate when the macro needs to inspect a workbook without editing its source, although it does not prevent the macro from changing other workbooks.

Why does a Mac VBA macro say it cannot find a file that exists?

The path may be stale, misspelled, or point to a cloud file that is not downloaded. The Mac may also restrict Excel’s access to the location. Try opening the file manually in Excel, check its current full path, and respond to any access prompt.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.