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 / How to move CurrentIte...
Power Automate
Answered

How to move CurrentItem / ExcelInstance in Error Handling

(0) ShareShare
ReportReport
Posted on by 71

Goodday,

 

I'm trying to close and copy/delete a CurrentItem Excel session when it triggers an Error in the flow. However, when the file is not open at the moment of an Error the Power Automate Desktop app fails to execute the If condition at line 4. 

I tried to resolve this with the If condition at line 3, but it still fails at line 4 when the Excel isn't open. 

 

Any ideas how to resolve this, or generally improve the Error Handling towards operational Excels?   

 

Martvis88_0-1713863778900.png

 

I have the same question (0)
  • Verified answer
    VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @Martvis88 ,

     

    Please find the below solution.

    In If window action instead of By Window Instance or Handle use By Title and/or Class. It is working. 

     

    VishnuReddy1997_0-1713865650632.png

     

    Code:

     Please copy the below code to your flow.

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\Downloads\\Sample_Template (2).xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    IF IsNotEmpty(ExcelInstance) THEN
     IF (UIAutomation.IfWindow.IsOpenByTitleClass Title: $'''Sample_Template (2) - Excel''' Class: $'''XLMAIN''') THEN
     Excel.CloseExcel.CloseAndSave Instance: ExcelInstance
     File.Copy Files: $'''C:\\Users\\Downloads\\Sample_Template (2).xlsx''' Destination: $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\New folder''' IfFileExists: File.IfExists.Overwrite CopiedFiles=> CopiedFiles
     File.Delete Files: $'''C:\\Users\\Downloads\\Sample_Template (2).xlsx'''
     END
    END

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @Martvis88 

    Instead checking the instance. you can create label and next place close excel action like below screenshot. It should work in both ways even though the excel instance already closed also.

     

    Deenuji_0-1713865945900.png

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • martvis Profile Picture
    71 on at

    Thank you for the quick responses Deenuji and VishnuReddy1997. I now resolved this with the additional Title and/or Class condition, works like a charm. Will experiment with the Exception Handling methods in the coming weeks to see how 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

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 308 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 171 Super User 2026 Season 2

#3
Haque Profile Picture

Haque 137 Super User 2026 Season 2

Last 30 days Overall leaderboard