How to Add Page Numbers to Word Documents in Power Automate
Headers, footers, and page numbers are often the final touches a Word document needs to look organized and professional. Writers don’t always remember to include that content, however, and the idea of going back through dozens of files to add superfluous content can be a little daunting.
Thankfully, there’s an easy way to add all that content to a Word document after it’s created. We can simply design a flow in Power Automate which cycles through each DOCX file in a target folder, adding headers, footers, or page numbers as we see fit.
In this article, we’ll focus on adding page numbers to a folder full of DOCX documents in a quick instant cloud flow. We’ll use the Cloudmersive Document Conversion connector to get the job done.
We’ll start by adding a List files in folder (OneDrive) or List files (SharePoint) action into our flow. Both of these actions retrieve useful information about files located in a specific folder, including the file IDs, which we’ll soon use to bring DOCX file bytes into our flow.
In our next step, we’ll add a Get file content action that retrieves file bytes from each file in our folder using the file IDs. Power Automate will place this action in a For each control to run through each document in our folder.
Within the For each control, we’ll add a new action and search for Cloudmersive connectors. We’re looking for the Cloudmersive Document Conversion connector with the green logo.
To view the actions list, we’ll click “See more,” and from there, we’ll select the first option on the list titled Add page number to footer in a Word DOCX document.
Before we can configure our request, we’ll first need to create our Cloudmersive Document Conversion connection. To do that, we’ll need to get a free Cloudmersive API key by creating a free account on the Cloudmersive website. These allow a limit of 800 API calls per month with no commitments (our API call limit will reset at the beginning of each month).
When we’re ready to configure our request, we’ll click “Show all” to view the advanced parameters.
Structuring this request is extremely simple. We just need to add our file bytes in the InputFileBytes parameter, and then include any text we want to prepend the page numbers added to our document. In my example, I’ll leave the latter option blank.
Cloudmersive Document Conversion actions like this one automatically convert our documents into temporary editing URLs to speed up the process of chaining edits together across multiple Document Conversion actions. The final versions of our edited documents can be downloaded from those URLs when the process is complete using a Document Conversion action called Finish editing document, and download result from document editing.
Since we’re only adding page numbers in this workflow, we’ll add the Finish editing document to our flow now, and we’ll pass the body/EditedDocumentUrl value from our Add page number action.
Now that we’ve returned file bytes to our flow, we’ll add a Create file (or Update file) action to apply the changes in a new DOCX document. In my example, I’ll be creating new files with slightly modified names from the originals.
We’ll now save and test our flow. When that process wraps up, we’ll find page numbers in the footer section of each file in our DOCX folder.
And that’s all there is to it! Now we can easily add page numbers to DOCX documents after they’ve been created & saved in a folder.