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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Clear Objects in an Ex...
Power Automate
Unanswered

Clear Objects in an Excel File with Power Automate

(0) ShareShare
ReportReport
Posted on by 98

Hi All,

Could anyone lecture me on how to clear objects(image) in an excel file with flow?

I looked for a way to run the excel script which ended up no success.

 

Any advise will be so much appreciated.

Thanks,

Categories:
I have the same question (0)
  • PhilipTreacy Profile Picture
    120 on at

    Hi @KenJapan 

     

    Write a macro in the Excel file and then call it from PA.

     

    pa-run-macro.png

     

    This macro will delete all images from all worksheets - here's an example excel file with the macro in it.

     

    Sub Delete_All_Images_In_Workbook()
    
     For Each ws In ActiveWorkbook.Worksheets
    
     For Each img In ws.Pictures
    
     img.Delete
    
     Next img
    
     Next ws
    
    End Sub

     

    Regards

     

    Phil

  • KenJapan Profile Picture
    98 on at

    Thanks for the tip, but I couldn't find 'launch excel' or 'run macro' connector in the flow....

  • Community Power Platform Member Profile Picture
    on at

    @KenJapan - The above solution is provided for Power Automate Desktop not Power Automate Cloud, so you will not find those activities in Power Automate Cloud.

  • KenJapan Profile Picture
    98 on at

    Understood. Any idea for the PA cloud??

  • Verified answer
    PhilipTreacy Profile Picture
    120 on at

    Hi @KenJapan 

     

    To do the same thing 'in the cloud' you can use this Office Script in your Excel file.  In Excel Online, go to the Automate tab -> New Script and paste this in.  Give the script a name and save it.

     

     

    function main(workbook: ExcelScript.Workbook) {
     
     let sheets = workbook.getWorksheets();
    
     for (let sheet of sheets) {
    
     sheet.getShapes().forEach((shape, index) => {
     if (shape.getType() === ExcelScript.ShapeType.image) {
     shape.delete();
     }
     }); 
     }
    }

     

     

    Here's my example flow.  I called the script Delete_All_Images

    deleteimages.png

     

    I've tested this code and it works.

     

    regards

     

    Phil

  • KenJapan Profile Picture
    98 on at

    It worked! Thank you sooo much!

    Love the community😀

  • SvenVerheyden Profile Picture
    2 on at

    Hi,

     

    I was searching for a way to remove objects from excel files.

    Found this discussion and tried but it does not work.

    Maybe it's because of a different object...

    My objects see picture 

     

    Maybe anyone can help me out

     

    Thanks a lot.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard