Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

Issues deleting sheets from excel workbook using office script

I am using @DamoBird365's tutorial on how to separate an excel workbook into multiple files.

The initial file is a macro enabled worksheet stored in sharepoint.


When trying to run the delete script I am running into the following error: 

"We were unable to run the script. Please try again.\nRuntime error: Line 8: Cannot read property 'delete' of undefined
Due to the file being macro enables I had to add in a condition to remove certain sheets from the worksheet listing. Please see screen shots included:
excel sheets flow 1.pngexcel sheets flow 2.pngexcel sheets flow 3.png
Any advice or assistance would be highly appreciated.

Accepted Solutions



You’ve got extra [] around your array for sheets to delete. Check how you’ve built that.



View solution in original post

Super User
Super User

Hi @KCarlton96 


Might just be that you need to use Id rather than identifier for the office script (Delete Sheets via Script) file parameter.



Hi @DamoBird365 ,

Thanks for your response. That produced the same error I mentioned above, so I'm still stuck unfortunately.

Hi @KCarlton96 


Can you share a screenshot? And copy the output for the failing action.



Hello @DamoBird365 ,


Sure. See below:

excel sheets flow 4.pngexcel sheets flow 5.png



You’ve got extra [] around your array for sheets to delete. Check how you’ve built that.



Hi @DamoBird365,


Thank you so much. Power Automate put it in when I added the body of the filter array to that field.


Hope you and yours are safe and well

Helpful resources

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.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (1,625)