VBA to refresh Power Query on proteched workbook

Thomas Meier 1 Reputation point
2021-01-29T04:33:51.613+00:00

I have two files:

  • A protected data source (File A)
  • A report (File B)

File A is connected to File B via Power Query (data source | Workbook | .xlsx). When I want to refresh File B (Data | Refresh All) I get an error message "[DataFormat.Error] File contains corrupted data"

Found out this is related to the protection of File A. So when I open File A after providing the password the data refreshes.

Here's what I'd like to do:

  • Get some VBA code to open File A (with the password VBA)
  • Run the query to refresh the data - how would this query look like in VBA?
  • Close File A and ensure it remains password protected

Related to this is it possible to open File A in the background without the user seeeing it?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
40,271 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Inbar Privman 1 Reputation point
    2021-02-17T12:59:46.92+00:00

    Hi @Thomas Meier ,

    Thank you for your feedback.
    We are aware of this issue, but we do not have a time estimate on when it will be fixed.
    In the meantime, you can vote for this idea on User Voice.

    Thank you,
    Inbar, Excel Team

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.