Formula.Firewall Issue

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,632
Office Version
  1. 365
Platform
  1. Windows
I have an Excel file that uses Power Query to get data from two Access tables.

The query is executed via the following VBA code in the Workbook_Open code
Code:
ActiveWorkbook.Connections("Query - SourceFileName").Refresh
ActiveWorkbook.Connections("Query - GoodsOut").Refresh

The SourceFileName query has three steps
1 - = Excel.CurrentWorkbook(){[Name="tblFilePath"]}[Content] - Where 'tblFilePath' holds the location of the Access database
2 - = Table.TransformColumnTypes(Source,{{"File_Path", type text}})
3 - = #"Changed Type"{0}[File_Path]

This is then referrred to for two other queries to get data from two tables in Access
= Access.Database(File.Contents(SourceFileName&"\StockMovement.accdb"), [CreateNavigationProperties=true])

When I have to replace the current Excel file that holds the above with an updated file, I get the Formula.Firewall message when the query that refers to the SourceFileName tries to execute.

To resolve this I have to go into the Query Settings and change the Privacy level to ignore for the workbook and then save the file.

As the file can be used as read-only, if it is open and someone else opens it, the VBA bugs out on
Code:
ActiveWorkbook.Connections("Query - SourceFileName").Refresh
ActiveWorkbook.Connections("Query - GoodsOut").Refresh

It's becoming more of an issue for me as I am building more files that uses PQ and ideally I'd like to implement a fix rather than having to manually set the privacy levels as and when it bugs out.

TIA
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Below is the Advanced Editor code which might make my issue a bit clearer

Getting the location of the data in the Access file
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="tblFilePath"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"File_Path", type text}}),
    Source_Data_File_Path = #"Changed Type"{0}[File_Path]
in
    Source_Data_File_Path

Refreshing the file with the required data in access
Code:
let
    Source = Access.Database(File.Contents(SourceFileName&"\StockMovement.accdb"), [CreateNavigationProperties=true]),
    _GoodsIn = Source{[Schema="",Item="GoodsIn"]}[Data]
in
    _GoodsIn
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top