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 / Close excel workbook b...
Power Automate
Unanswered

Close excel workbook by run script

(0) ShareShare
ReportReport
Posted on by

Hello, I use run scrip to modify excel file like picture below, then save a copy.

 

And I need to delete the original excel file.

 

But the delete step failed, I think it's because of the run script, the excel is still running.

 

How could I add code in script to close excel after modification?

 

Thanks.

 

 

 

magical0221_1-1665032752191.png

 

Categories:
  • Yutao Huang Profile Picture
    Microsoft Employee on at

    Yea normally the workbook will be locked for some time to make sure the changes made to it are saved completely. You can try to add a "Delay" action before deleting the file. I did some experimentation and a 10 minutes delay worked for me. I also tried delaying for 30 seconds, 1 minutes, 3 minutes, and 5 minutes but none allowed me to delete the file.

     

    Yutao_0-1665290192240.png

    Although to play safe, you probably can add some checking and retrying loop (e.g., check if "Delete file" fails, repeat "Delay" then delete again) to make sure the file can be eventually deleted.

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 377

#2
11manish Profile Picture

11manish 292 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 128

Last 30 days Overall leaderboard