Skip to content

Instantly share code, notes, and snippets.

@dannguyen
Last active February 26, 2025 18:14
Show Gist options
  • Save dannguyen/5a0f5a895c419966e44b6c25a4a2373b to your computer and use it in GitHub Desktop.
Save dannguyen/5a0f5a895c419966e44b6c25a4a2373b to your computer and use it in GitHub Desktop.

Revisions

  1. dannguyen revised this gist Feb 26, 2025. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion fix-macos-excel-access-denied-powerquery.md
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ in
    Source
    ```

    The computer that originally created and saved the workbook had no problem; the different laptop utterly refused to open the CSV. Even after granting Full Disk Access via macOS Settings » Privacy and Security options.
    The computer that originally created and saved the workbook had no problems re-opening the book and working with the Power Query command. The other laptop just utterly refused to open the CSV. Even after granting Full Disk Access via macOS Settings » Privacy and Security options.


    ## Solution
    @@ -78,6 +78,8 @@ The `MsgBox` command should successfully execute:

    Save, and restart Excel. You should be good to go.

    **Note:** You have to completely exit out of Excel, not just close the file.


    ### Also: Enable "Allow combining data from multiple sources"

  2. dannguyen revised this gist Feb 26, 2025. 1 changed file with 18 additions and 1 deletion.
    19 changes: 18 additions & 1 deletion fix-macos-excel-access-denied-powerquery.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,20 @@ So you're trying to use macOS Excel's Power Query Editor to load an external fil
    isExpected: True
    ```

    I ran into this error when saving a workbook on Dropbox, and then opening it from a different laptop. The computer that originally created and saved the workbook had no problem; the different laptop utterly refused to open the CSV. Even after granting Full Disk Access via macOS Settings » Privacy and Security options.
    I ran into this error when saving a workbook on Dropbox, and then trying to open and work on it from a different laptop. Opening the Excel workbook was fine, the error message came from the Power Query command that imported the CSV, e.g.

    ```pq
    let
    Source = Csv.Document(
    File.Contents("/Users/dan/Dropbox/mybook/mydata.csv"),
    [Delimiter = ",", Columns = 2, QuoteStyle = QuoteStyle.None]
    )
    in
    Source
    ```

    The computer that originally created and saved the workbook had no problem; the different laptop utterly refused to open the CSV. Even after granting Full Disk Access via macOS Settings » Privacy and Security options.


    ## Solution

    @@ -59,6 +72,10 @@ It will likely ask you to grant access to the enclosing folder, so do that too:

    <img width="453" alt="image" src="https://gist.github.com/user-attachments/assets/d178d477-fcd3-45a0-9cf0-7f1880f2862e" />

    The `MsgBox` command should successfully execute:

    <img width="857" alt="image" src="https://gist.github.com/user-attachments/assets/cb0133a1-a613-40b7-b94e-b2483c0650ea" />

    Save, and restart Excel. You should be good to go.


  3. dannguyen revised this gist Feb 26, 2025. 1 changed file with 26 additions and 4 deletions.
    30 changes: 26 additions & 4 deletions fix-macos-excel-access-denied-powerquery.md
    Original file line number Diff line number Diff line change
    @@ -28,14 +28,36 @@ tl;dr: Have Excel ask you to grant access to that file. But since Excel (in my e

    ### 1. Force Excel to ask for access privileges by executing VB code that refers to the file path

    Go to the Microsoft Visual Basic editor inside of Excel, and open up the "Immediate" code window, i.e. View » Immediate Window or use the keyboard shortcut Ctrl-Cmd-G
    Go to the Microsoft Visual Basic editor inside of Excel (i.e. Developer ribbon » Visual Basic)

    Execute the following benign code (replace with the absolute path to the file you're trying to access):
    <img width="814" alt="excel screenshot of VB editor" src="https://gist.github.com/user-attachments/assets/f5637c1a-2a58-4b25-97c7-17595bed357e" />

    Then open up the "Immediate" code window, i.e. **View » Immediate Window** or use the keyboard shortcut Ctrl-Cmd-G.

    Enter, then execute following benign code which simply tries to print the directory of the data file via a message alert box:

    *(obviously, replace with the absolute path to the file you're trying to access)*

    ````vb
    MsgBox Dir("/Users/dan/Desktop/mybook/mydata.csv")
    MsgBox Dir("/Users/dan/Dropbox/mybook/mydata.csv")
    ````
    It will bring up a file selection dialog box asking you to manually grant access to the given file.
    <img width="669" alt="image" src="https://gist.github.com/user-attachments/assets/4a5871dd-b5a8-42ff-b27c-097132a48970" />

    Executing that line of code will bring up a dialog box asking you to manually grant access to the given file.

    > Additional permissions are required to access the following files:
    > /Users/dan/Dropbox/mybook/mydata.csv
    > Microsoft Excel needs access to the file named "mydata.csv". Select the item to grant access.
    <img width="639" alt="image" src="https://gist.github.com/user-attachments/assets/af6557d1-a3b4-4201-b62a-8dd09d998971" />

    Select the file and grant access:

    <img width="597" alt="image" src="https://gist.github.com/user-attachments/assets/4b8d0c4e-b0ca-4114-94d4-95b362696f70" />

    It will likely ask you to grant access to the enclosing folder, so do that too:

    <img width="453" alt="image" src="https://gist.github.com/user-attachments/assets/d178d477-fcd3-45a0-9cf0-7f1880f2862e" />

    Save, and restart Excel. You should be good to go.

  4. dannguyen revised this gist Feb 26, 2025. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions fix-macos-excel-access-denied-powerquery.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,20 @@
    # How to fix "DataSource.Error Access to the path '/yourpath.csv' is denied error" in macOS Excel Power Query

    One of the most incomprehensible errors I have ever run into, with Microsoft forums and ChatGPT/Claude being almost totally useless.
    <img width="560" alt="excel error box: [DataSource.Error] Access to the path '/Users/dan/Dropbox/mybook/mydata.csv' is denied." src="https://gist.github.com/user-attachments/assets/35694df6-ecc2-4dd2-b94f-a2dcbc15f040" />


    One of the most incomprehensible errors I have ever run into, with Microsoft forums and ChatGPT/Claude being almost totally useless. Hopefully anyone else running into this situation will come across this gist and save themselves hours of frustration.

    Huge thanks to [Mr. Excel for the solution](https://youtu.be/chBlyDrejHo?si=JoWYoPGkQSE24_fN&t=369), with a major assist by [r/excel](https://www.reddit.com/r/excel/comments/17euyxj/datasourceerror_mac_powerquery_driving_me_nuts/)

    ## Background

    So you're trying to use macOS Excel's Power Query Editor to load an external file from disk, e.g. `/Users/dan/Desktop/mybook/mydata.csv`, only to get this error:
    <img width="698" alt="power query editor error [DataSource.Error] Access to the path '/Users/dan/Dropbox/mybook/mydata.csv' is denied." src="https://gist.github.com/user-attachments/assets/56941b26-5f59-4f02-a868-2d123a081888" />

    So you're trying to use macOS Excel's Power Query Editor to load an external file from disk, e.g. `/Users/dan/Dropbox/mybook/mydata.csv`, only to get this error:

    ```
    • [DataSource.Error] Access to the path '/Users/dan/Desktop/mybook/mydata.csv' is denied.
    • [DataSource.Error] Access to the path '/Users/dan/Dropbox/mybook/mydata.csv' is denied.
    Details
    isRecoverable: True
    isExpected: True
  5. dannguyen revised this gist Feb 26, 2025. 1 changed file with 11 additions and 4 deletions.
    15 changes: 11 additions & 4 deletions fix-macos-excel-access-denied-powerquery.md
    Original file line number Diff line number Diff line change
    @@ -4,15 +4,22 @@ One of the most incomprehensible errors I have ever run into, with Microsoft for

    Huge thanks to [Mr. Excel for the solution](https://youtu.be/chBlyDrejHo?si=JoWYoPGkQSE24_fN&t=369), with a major assist by [r/excel](https://www.reddit.com/r/excel/comments/17euyxj/datasourceerror_mac_powerquery_driving_me_nuts/)

    ## Background

    So you're trying to use macOS Excel's Power Query Editor to load an external file from disk, e.g. `/Users/dan/Desktop/mybook/mydata.csv`, only to get this error:

    > [DataSource.Error] Access to the path '/Users/dan/Desktop/mybook/mydata.csv' is denied.
    > Details isRecoverable: True
    > isExpected: True
    ```
    • [DataSource.Error] Access to the path '/Users/dan/Desktop/mybook/mydata.csv' is denied.
    Details
    isRecoverable: True
    isExpected: True
    ```

    I ran into this error when saving a workbook on Dropbox, and then opening it from a different laptop. The computer that originally created and saved the workbook had no problem; the different laptop utterly refused to open the CSV. Even after granting Full Disk Access via macOS Settings » Privacy and Security options.

    The solution? Have Excel ask you to grant access to that file. But since Excel (in my experience) won't even know to do that, you can force it to with a simple VB command referencing the file path.
    ## Solution

    tl;dr: Have Excel ask you to grant access to that file. But since Excel (in my experience) won't even know to do that, you can force it to with a simple VB command referencing the file path.

    ### 1. Force Excel to ask for access privileges by executing VB code that refers to the file path

  6. dannguyen created this gist Feb 26, 2025.
    45 changes: 45 additions & 0 deletions fix-macos-excel-access-denied-powerquery.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    # How to fix "DataSource.Error Access to the path '/yourpath.csv' is denied error" in macOS Excel Power Query

    One of the most incomprehensible errors I have ever run into, with Microsoft forums and ChatGPT/Claude being almost totally useless.

    Huge thanks to [Mr. Excel for the solution](https://youtu.be/chBlyDrejHo?si=JoWYoPGkQSE24_fN&t=369), with a major assist by [r/excel](https://www.reddit.com/r/excel/comments/17euyxj/datasourceerror_mac_powerquery_driving_me_nuts/)

    So you're trying to use macOS Excel's Power Query Editor to load an external file from disk, e.g. `/Users/dan/Desktop/mybook/mydata.csv`, only to get this error:

    > [DataSource.Error] Access to the path '/Users/dan/Desktop/mybook/mydata.csv' is denied.
    > Details isRecoverable: True
    > isExpected: True
    I ran into this error when saving a workbook on Dropbox, and then opening it from a different laptop. The computer that originally created and saved the workbook had no problem; the different laptop utterly refused to open the CSV. Even after granting Full Disk Access via macOS Settings » Privacy and Security options.

    The solution? Have Excel ask you to grant access to that file. But since Excel (in my experience) won't even know to do that, you can force it to with a simple VB command referencing the file path.

    ### 1. Force Excel to ask for access privileges by executing VB code that refers to the file path

    Go to the Microsoft Visual Basic editor inside of Excel, and open up the "Immediate" code window, i.e. View » Immediate Window or use the keyboard shortcut Ctrl-Cmd-G

    Execute the following benign code (replace with the absolute path to the file you're trying to access):

    ````vb
    MsgBox Dir("/Users/dan/Desktop/mybook/mydata.csv")
    ````
    It will bring up a file selection dialog box asking you to manually grant access to the given file.

    Save, and restart Excel. You should be good to go.


    ### Also: Enable "Allow combining data from multiple sources"

    You already need to do this step anyway, whether you're on macOS or Windows:

    In the Power Query Editor » Options » **Privacy**, be sure to enable the option that says:

    > Allow combining data from multiple sources. This could expose sensitive or confidential data to an unauthorized person.
    <img width="637" alt="image" src="https://gist.github.com/user-attachments/assets/ca6060d2-4274-48dc-a916-25185d73e0a7" />


    ## References

    - [MrExcel.com Excel for Mac - Power Query Three Missing Connector Workarounds - Episode 2597](https://youtu.be/chBlyDrejHo?si=JoWYoPGkQSE24_fN&t=369) (6 minute mark)
    - r/excel: [DataSource.Error (mac, powerquery) driving me nuts](https://www.reddit.com/r/excel/comments/17euyxj/datasourceerror_mac_powerquery_driving_me_nuts/)