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.

