cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SQL-Power
Frequent Visitor

refresh excel every morning

Hello everyone,

 

i try the following.

A workflow that every morning open my excel file, refreshed it, saves and close again.

What would the process look like? 🤗

Thank you in advance

 

SQLPower_0-1631774799403.png

 

 

 

15 REPLIES 15
RemcoV16
Frequent Visitor

Hi,

 

Are you working in an Excel Online file?

In that case, you can have a Flow run every day "Reoccurence" and have an Excel Script refresh the data.

If you're unfamiliar with this or unsure how to do so, let me know, and I'll show you.

 

Regards,

Remco

Hi @RemcoV16 ,

 

yes. Please show me how i can update this. I thank you very much.  🙂

 

Regards,

SQL-Power

RemcoV16
Frequent Visitor

Hi,

 

First ensure that your Excel file is stored in an online location (Like Drive or SharePoint). Not sure how it works with an offline Excel file. Then, I would build something like this:

 

RemcoV16_0-1632146020714.png

The Flow triggers daily at 8:00 AM now and runs a created script (similar to Excel Macro's).

You can either record the script yourself, or paste the code below in a new script.

 

function main(workbook: ExcelScript.Workbook) {
  // Refresh all data connections
  workbook.refreshAllDataConnections();
}

 

Both can be done via the "Automate" Tab in Excel (see highlighted below (even though in Dutch)):

RemcoV16_1-1632146134769.png

After refreshing the data, the Flow will send an email to the email-address filled in. 

 

If I have answered your question, please mark my post as a solution
If you have found my response helpful, please give it a thumbs up.

 

Regards,

Remco

Thank for your solution but i have a little problem.

 

i cant see my script although i creates one.

Can you see your script within Excel Online? Otherwise it might not have saved correctly.

If you have added the script with your Flow open, be sure to save the Flow, refresh the page and try again.

i dont know why i cant see my script ... 😕 i already saved an close the excel file

1.JPG2.JPG

RemcoV16
Frequent Visitor

If you open your Excel online, do you see the script?

 

RemcoV16_0-1632212522239.png

If it does not show here, your Flow won't find it either.

 

Thank you very much for your efforts. I managed to create.

But unfortunately I am still faced with one of the following questions / problems.

 

 

I created the workflow and I want it to run every minute.
After the workflow was successfully completed, I opened the Excel list, which is saved on my desktop, and the data has not been updated: /

Do I have to make further settings in the Excel list?

Hi,

 

I'm unsure whether you are able to do this with a file that is stored on your desktop.

Could you try saving the Flow in SharePoint or Drive, and see if the file gets updated that way?

the code isn't working 

SQLPower_0-1632230427724.png

and the excel file is in the onedrive 🙂 

 

I am trying to accomplish the same thing. I have been working on this for days.
Here is what we have.
An excel file saved to SharePoint library:

  • excel file has two data connections queries each to a different SharePoint list
  • excel file has 4 power query tables performing tasks
  • excel file exceeds 15,000 rows

This works fine on excel desktop - manual Refresh All works perfect, there is a setting to refresh on file open and every 30 minutes - those also work fine on desktop.

What we are trying to do is AUTOMATE the refresh all, then send the resulting refreshed excel file attached to an email. ( the flow to send the scheduled email works perfectly!)
HOWEVER; The data is NOT refreshed when fetched by the flow.
Any help would be greatly approciated.

chandlers201
New Member

Hi,

I have created the following office script to schedule an automated refresh on the Excel that uses Powerquery every day. The power automate flow executes fine with no errors but the office script does not refresh. I have also manually refreshed which does work but the automation doesn't work.
 
Could you please assist here?

chandlers201_0-1641734919483.png

chandlers201_1-1641735100853.png

 

Hello:
We have the same issue. The online script will not run the refresh. I even tried adding a delay, then close> still no refresh.
As an alternative I attempted to use 'Desktop Power Automate'  - and it worked, the excel file (with power queries) on sharepoint > opened> refreshed> waited> and closed.  

BUT !!!
That did not solve our requirement - only the first
step.
Step 2 - need to schedule a daily email with the file attached after refresh.
To call desktop flow from online is a 'premium' license - which we don't have.
SO.......

online PA - wont refresh file or open file do to query

desktop - cant run schedule email

online script - cant send email
ANY IDEAS?

rrm1
New Member

Hello everyone.

 

I have been working on this also for some time and found a solution that is working for me.

 

In my case I have to refresh the data in one worksheet with the data in another (I haven't tried this for external data sources).

 

What I did was to add to the script some hide/unhide worksheet orders, leaving the document as before. However, the document refreshed. Something like this (for my document):

 

function main(workbook: ExcelScript.Workbook) {
  // Refresh all data connections
  workbook.refreshAllDataConnections();
  let form1 = workbook.getWorksheet("Form1");
  // Set sheet visibility to ExcelScript.SheetVisibility.visible
  form1.setVisibility(ExcelScript.SheetVisibility.visible);
  let def = workbook.getWorksheet("Def");
  // Set sheet visibility to ExcelScript.SheetVisibility.visible
  def.setVisibility(ExcelScript.SheetVisibility.visible);
  let normas = workbook.getWorksheet("Normas");
  // Set sheet visibility to ExcelScript.SheetVisibility.visible
  normas.setVisibility(ExcelScript.SheetVisibility.visible);
  let solicitud = workbook.getWorksheet("Solicitud");
  // Set sheet visibility to ExcelScript.SheetVisibility.visible
  solicitud.setVisibility(ExcelScript.SheetVisibility.visible);
  // Set sheet visibility to ExcelScript.SheetVisibility.hidden
  solicitud.setVisibility(ExcelScript.SheetVisibility.hidden);
  // Set sheet visibility to ExcelScript.SheetVisibility.hidden
  def.setVisibility(ExcelScript.SheetVisibility.hidden);
  // Set sheet visibility to ExcelScript.SheetVisibility.hidden
  normas.setVisibility(ExcelScript.SheetVisibility.hidden);
  // Set sheet visibility to ExcelScript.SheetVisibility.hidden
  form1.setVisibility(ExcelScript.SheetVisibility.hidden);
}
 

Hope this also works for you.

Nic-AF
New Member

I was also trying to use Power Automate to refresh an Excel file which pulls data from a Sharepoint List.  After researching and trying, my conclusion is that Enterprise license is needed.  Correct me if I'm wrong.

 

Currently in Excel, if you click Get Data, you need Enterprise license in order to select Sharepoint List as a source, which I don't have.  The way I build refresh-able connections to Sharepoint Lists is by going to the List, click the export button which downloads a query file, and open the file in Excel.  This connection works fine in desktop Excel, but DOES NOT work in the web version, and I assume if you use Power Automate to refresh this connection, it will not refresh. 

 

Seems to be a dead end for me, so I did a work around.

 

Since the Sharepoint List is populated by Power Automate, I made change to the Flow so that whenever an item is inserted into the List, also add a new row to the Excel file.  This way the file is always up to date.

 

Even if the List is not populated by Power Automate, you can probably set up a Flow triggered by insertion, and add that insertion to the Excel.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,738)