How to Remove Slides from a PowerPoint PPTX Presentation in Power Automate
In today’s Power Automate walkthrough, we’ll focus our attention on manipulating MS PowerPoint PPTX files in a helpful & relevant way.
Specifically, we’ll learn how to cut out a range of slides from our PPTX files using the Cloudmersive Document Conversion connector. We’ll leverage an action titled Delete, remove slides from a PowerPoint presentation document to select a range of slides (inclusive) for removal, and we’ll create the new “trimmed” version of our PPTX documents in a separate folder.
In our example use-case, we’ll imagine that several PowerPoint PPTX files in a SharePoint folder contain the same 2nd and 3rd slides, which look like the below example:
In our flow, we’ll remove the 2nd and 3rd slides from each presentation without changing any other content in our PowerPoint file.
Create an Instant cloud flow
To begin, we’ll create a manually triggered Instant cloud flow (this option is ideal for testing).
List PowerPoint PPTX files in a SharePoint folder and retrieve file bytes for each
In our first two steps of our flow, we’ll use the List folder and Get file content actions (found on the SharePoint connector) to collectively retrieve PPTX file bytes from our target folder. List folder retrieves file identifier (Id) values for each file in a particular folder and Get file content retrieves file bytes using the Id values.
We’ll notice that Power Automate created a For each control and placed our Get file content action within that control. The Id value is an array, and the For each control ensures subsequent flow actions occur for each value contained in the array.
Find and add the Delete, remove slides action
Within the For each control, we’ll add a new action and search the Power Automate library for Cloudmersive connectors.
Specifically, we’ll locate the Document Conversion connector, which has a green logo.
To view the full actions list, we’ll click “See more”. From there, we’ll use the CTRL+F search function in our browser to find the Delete, remove slides from a PowerPoint presentation action.
Create a Cloudmersive Document Conversion connection
When we select this action, we’ll reach a window asking us to create our Cloudmersive Document Conversion connection. To do that, we’ll need a free Cloudmersive API key, and we can get one by registering a free account on the Cloudmersive website.
Free accounts allow a limit of 800 API calls/month with no commitments; for reference, this example flow is using a free API key as well.
Configure the Delete, remove slides request
To configure our Delete, remove slides request, we’ll first click “Show all” to enumerate our parameters. In this case, the Advanced parameters are the only request parameters available to us.
Let’s now review each field so we can understand how to structure our request properly.
- The ReqConfig/EndDeleteSlideNumber parameter takes a positive integer and represents the final slide in the range of slides to be deleted in our Delete, remove slides request.
- The ReqConfig/InputFileBytes parameter takes PPTX file bytes from our Get file content action.
- The ReqConfig/InputFileUrl parameter accepts a URL value in operations where file URLs are utilized in place of file byte strings.
- The ReqConfig/StartDeleteSlideNumber parameter takes a positive integer and represents the first slide in the range of slides to be deleted in our Delete, remove slides request. It’s important to note that PowerPoint PPTX files use a 1-based slide index; the first slide in our presentation document is slide 1.
Here’s how we’ll configure our request to remove slides 2 and 3 from each presentation in this example:
Now that we’ve asked our flow to remove slides 2 and 3 from each PowerPoint PPTX in our SharePoint folder, we’ll create a new version of each file using a Create file action.
We could alternatively use an Update file action to replace our original PowerPoint PPTX content with the output of this flow; we’re avoiding that option in this example so we can show a before/after in our walkthrough.
As shown in the above screenshot, we can dynamically name our new files by combining a new string with the original Name value from our List folder action.
Run a test & check the results
We’ll now save our flow and run a test.
When our test finishes, we’ll find our new files in our target SharePoint folder.
In this example, we saved the edited PowerPoint PPTX files alongside the original versions in the same folder.
If we refer back to my original screenshot of these two files, we’ll notice the 2nd and 3rd slides are now missing for each, and each presentation now jumps straight from the 1st slide to what was originally the 4th.
Conclusion
In this article, we learned how to quickly & easily remove a range of slides from any PowerPoint PPTX presentation using the SharePoint and Cloudmersive Document Conversion connectors in Power Automate.
As a quick note — If we’re interested in deleting two separate ranges of slides from the same PowerPoint, we can chain two Delete, remove slides actions together by passing OutputContent from the first iteration of this action to the second.
If you found this walkthrough useful, be sure to check back on our blog for more example flows in the future!