Workbook Open Event Issues with Power Query Connections

leishtheman

New Member
Joined
Oct 1, 2007
Messages
32
Hello

I have an issue I've been unable to resolve after lots of searching which I'd like to request help with if that's ok.

I have an excel workbook set up to monitor stock (equities) prices using power query connections to yahoo finance. The file refreshes the connections > looks for major falls in stock prices during the previous day > then generates email alerts listing all stocks where the daily fall has been greater than 10%. The script works correctly when I open the workbook and run it manually. My problem is that I don't want to have to run it manually, and when I automate the running of it it doesn't work correctly:

I run the the script off the workbook open event and open the workbook using windows task scheduler upon startup. When I do this the workbook doesn't open 'fully' in the sense of you being able to see the ribbon and worksheets etc, but rather it just displays the small 'loading' box you get when Excel is firing up. The workbook open event triggers nevertheless and it starts running the code, with it opening 'fully' once it has finished running the code. The problem is that the power query connection refreshes don't appear to be visible until the workbook is 'fully' open, meaning it generates the email alert using old data whereas I need it to generate the emails using the newly refreshed data.

I suppose my question in a nutshell is either - a) how do I get a workbook to 'fully' open before the workbook open event triggers, or b) how do I get power query connections to refresh fully in the background so I can pick up the refreshed data?

Many thanks in advance,

Andy Leishman.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,823
Messages
6,181,178
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