Running Power Query in a Closed Workbooks

hananak

Board Regular
Joined
Feb 10, 2022
Messages
110
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

I have two workbooks. They both are directly linked with Oracle Accounting software through Power Query. Every time when we want to see latest data. I have to go to those workbooks one by one. Run the query (once the query has finished running), save the files and close. After that I have separate file which contains all the Pivot tables reports that have connections to those workbooks. All I do is "Refresh All" and all the pivot tables reports are refreshed with the new data in them.

What I am trying to do is to have a button in my Pivot tables reports workbook. When I press it. It should run the queries in those closed workbooks which are directly linked with Oracle Accounting software. and alert me once the queries have successfully fetched the new data and then refresh all the pivot reports.

Currently, I have to go several times in those workbooks to run the queries, save and close during the day. It has becomes really frustrating to open the files, run the queries, save and close and then again do the same process.
There are not set timings otherwise I would have chosen to run the queries automatically after specific time interval.

I really appreciate in advance for your help please!
 
It's not lost it's just that the workbook is hidden. Click Unhide on the View tab, then select the workbook and save and close it. Then amend the update macro to:

Code:
Sub UpdateSourceDataFiles()
Application.screenupdating = false
With Workbooks.Open("path to workbook here")
   .Refreshall
   .Close Savechanges:=true
end with
Application.screenupdating = true
End Sub
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
It's not lost it's just that the workbook is hidden. Click Unhide on the View tab, then select the workbook and save and close it. Then amend the update macro to:

Code:
Sub UpdateSourceDataFiles()
Application.screenupdating = false
With Workbooks.Open("path to workbook here")
   .Refreshall
   .Close Savechanges:=true
end with
Application.screenupdating = true
End Sub
Normally, the PQ takes few minutes to fetch the new data but in this case the query run quickly and did not fetch any data. Pivot tables reports are also blank.

Any Thoughts?
 
Upvote 0
Did you turn off the background refresh for the queries as I mentioned earlier?
 
Upvote 0
Did you turn off the background refresh for the queries as I mentioned earlier?
Yes I did turn off the background refresh. Please see the images. When I refresh the Pivots tables reports. I get these errors.
 

Attachments

  • Error 2.PNG
    Error 2.PNG
    7.1 KB · Views: 15
  • Error 3.PNG
    Error 3.PNG
    13.7 KB · Views: 14
  • Error.PNG
    Error.PNG
    12 KB · Views: 14
Upvote 0
That looks like a problem with your queries, not the code. Can you refresh them manually without error?
 
Upvote 0
That looks like a problem with your queries, not the code. Can you refresh them manually without error?
Yes, I checked. The queries are working without error. It does take few minutes to update the queries as the data is large.
 
Upvote 0
If you turned off the background refresh then the queries should take the same time as normal.
 
Upvote 0
If you turned off the background refresh then the queries should take the same time as normal.
Now no errors. but the query does not refresh the data when I run the macro to run the query.?
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,109
Members
453,021
Latest member
Justyna P

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