1

I load a local Json file using Power Query in Excel. The source file is dynamic (the source file is picked up via button using FileDialog and then updated via VBA in the query formula). The query looks something like this:

let
    Quote = Json.Document(File.Contents("C:\last_loaded_file.json")),
                                         ^^^^^^^^^^^^^^^^^^^^^^^^ this is updated via VBA
    orderItems = Quote[orderItems],
    #"Converted to Table" = Table.FromList(orderItems, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #...,
    #...,
    #"Sorted Rows" = ...
in
    #"Sorted Rows"

The problem is that the last used file is saved in the query. Once I open the Excel and the local source file doesn't exist (e.g. on a different computer), the Excel will show up with an error.

[DataSource.Error] Could not find file 'C:\last_loaded_file.json'.

[DataSource.Error] Could not find a part of the path 'C:\folder\folder\...'.

Is there a way how to tell Excel NOT TO refresh power queries when opening Excel (because the source file doesn't exist)? The actual connection has all relevant checkboxes to refresh disabled. However, Excel keeps trying to refresh the power query (loading data from the unavailable Json file).

I also tried to change the query itself (via Power Query Advanced Editor) to avoid loading but I didn't find a way how avoid loading a non-existing file.

Any hints appreciated, thanks.

The error that always shows up when opening the Excel on different computer (where the source file doesn't exist). All Refresh checkboxes are disabled.

1 Answer 1

1

Well, the problem is Excel templates (*.xlst, *.xlmt). When you save a spreadsheet as a template, Excel asks:

This workbook contains external data. Do you want Microsoft Excel to clear the data before saving the template, and then automatically refresh the data whenever the template is opened?

Yes No Cancel

And the last user who saved the file as template hit the Yes button. This has caused the troubles with auto-refreshing the power query from non-existing file when opening the template.

Solution: Hit the No button when saving the template.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.