web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Launching Excel with R...
Power Automate
Answered

Launching Excel with Run Application

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, I am hoping someone can help with this issue. I am launching Excel using the Run Application function. I am doing this so the data connections will update when the file is open. The Launch Excel function doesn't perform the data connection Refresh for some reason. The issue I am having is that in order to close the application I have to have an Excel Instance variable which I can't seem to find. Any advice on a better way to do this or a way to set/find the variable is appreciated!

I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Try close Excel by sending keys Alt+F4.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the quick response. I tried {Alt}({F4}) to no avail. It didn't do anything.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Tested here and worked as expected:

    1) 'Run application' pointing to Excel.exe

    2) 'Wait' 5s to assure Excel loads

    3) 'Send keys' {Alt}({F4})

    Alt+F4 is shortcut to close Excel and other applications in Windows. Here it did exactly this.

    Be sure you're in the Excel window when sending keys. 

  • tkuehara Profile Picture
    667 on at

    Hi @Anonymous 

     

    You can "capture" Excel even without using "Launch Excel" action. I tried the code below and it worked as desired:

    tkuehara_0-1625704618150.png

    The "Attach to running Excel" produces the "ExcelInstance9" variable used in the "Close Excel" action.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for the reply. I tried using your solution with my Excel document but it keeps giving me an error stating my Excel Document can't be found. I was able to create a solution that uses a desktop recording to close the file. Seems like a hack and I would really like to figure this one out!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you for the reply. I tried using your solution with my Excel document but it keeps giving me an error stating my Excel Document can't be found. I was able to create a solution that uses a desktop recording to close the file. Seems like a hack and I would really like to figure this one out!

  • Riyaz_riz11 Profile Picture
    4,067 Super User 2026 Season 1 on at

    Hi @Anonymous 

     

    First try to use application and pass the respective excel file in run application,

    if u need to close excel use  by sending keys Alt+F4.

     

    Thanks,

    Ahammad Riyaz

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    Redundant "Attach to Excel File" commands will result in the error "the document cannot be found."  If that file is an active Excel instance within Power Automate, you cannot sent another Launch/Attach command, or you will get that error.  (I learned that one the hard way)

    I would rewrite your process to:
    1) Launch Excel
    2) Use UI elements to update the links by clicking the "Refresh All" button on the Data Ribbon under the Queries & Connections Section

    3) Save and Close Excel 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks Michael. That works!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 608

#2
Valantis Profile Picture

Valantis 416

#3
11manish Profile Picture

11manish 348

Last 30 days Overall leaderboard