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 / Best Way to use Attach...
Power Automate
Answered

Best Way to use Attach to Excel and Launch Excel at the same time

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I want my automated flow to recognize whether the mentioned Excel file is open or not. If its open, the Attach to Excel action should run, if it is not open, then the Launch Excel action should run.

 

What are the best ways in which the above mentioned constraint can be overcome?

 

Insights will be really helpful. Thanks! 

I have the same question (0)
  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The easiest way to do that would be to try and run the Attach to running Excel action first and handle its error. If it fails, then run the Launch Excel action. If it succeeds, then continue without launching Excel.

     

    An alternative could be using the If process action and checking if the Excel process is running. If it is, you could assume that the document is already open and use Attach to running Excel. But this approach is risky, because you could have an existing Excel process, but a different document, which would still lead to Attach to running Excel failing. There is no way to check the exact document that is open solely based on the process, apart from using some custom scripting in VBscript, PowerShell or CMD actions.

     

    If the Excel instance is visible, you could also use the If window action and check if an Excel window with the specific file name is open, since the file name will be in the window title. Then, if it is open, you can use the Attach to running Excel to attach to it. But if the instance is not visible, that won't work.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Perfect answer, as always. 2 thumbs up.  idk why, but when I click it, it gives 2, haha!

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Haha, it says your Kudo weighs 2: 

    Agnius_0-1689581747403.png

     

    Must be because you're a super user - meaning that if you kudo someone, the post really deserves it, haha.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    sdj04_0-1689651217555.png

    On Attach to Excel block error, the flow will go to the end of the block, running the Launch Excel Action. If there was no errors, the flow will jump to the label "Attached to Running Self Setup Instance". 

     

    Thanks for the insights @Agnius & @MichaelAnnis !

    P.S: Added y'all to my friends list😃

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    To avoid having to use Go to Label (I have a rule of not using these in our flows), I would have created a sub-flow with the Launch Excel action and made the On block error call that sub-flow if Attach to running Excel failed. But this works, too 😊

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I believe what you mentioned is a much more cleaner approach than Go To + Label.

    Let me see If I could clean up some parts of my workflow.

     

    Thank you very much @Agnius !

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 248 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 160 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 142 Super User 2026 Season 2

Last 30 days Overall leaderboard