Power Automate Desktop can open Word files, find and replace text, save a copy and close the document. Use Word actions rather than screen coordinates wherever possible, and never run a bulk edit against the only copy of a document library.
Fact-checked against the current Microsoft Power Automate Desktop Word action reference on 24 August 2026.
First decide what you are changing
This pattern suits controlled text replacement, for example:
- an old company name;
- a standard footer sentence;
- a known SharePoint URL;
- a document owner label.
It is a poor fit for changing SharePoint library metadata. Update SharePoint columns through SharePoint instead of opening every Word document.
It is also a poor fit when the documents use several templates, tracked changes, protected sections, macros or complex fields. Inspect a representative sample before assuming one replacement rule fits everything.
Prepare a safe test set
- Copy five representative documents to a test folder.
- Include a protected file, a file without the target text and a file containing the text more than once.
- Decide whether the original should be preserved, overwritten or versioned.
- Write down the expected result for each file.
- Keep the production library out of scope until every test passes.
Build the desktop flow
1. Get the files
Use the folder actions to retrieve .docx files from the approved input folder. Exclude temporary files that begin with ~$.
2. Loop through each file
Use For each and keep the current file path in a clearly named variable.
3. Launch Word and open the document
Use the Word action that launches Word and opens the current document. Microsoft documents a Word instance variable for subsequent actions.
Avoid UI automation unless the Word action set cannot perform the operation. Screen selectors and keyboard shortcuts are more sensitive to dialogs, updates and focus changes.
4. Find and replace
Use Find and replace words in Word document with an exact, reviewed search value and replacement.
Be explicit about:
- matching letter case;
- replacing every match or one match;
- whole-word behaviour;
- whether headers, footers or text boxes are in scope.
Do not replace a short ambiguous token such as old across a legal document set.
5. Save a copy
Write the result to an output folder first. Use a collision rule that does not silently overwrite a previous result.
6. Close Word
Close the document and Word instance in both success and failure paths. A stranded Word process can block later files.
Record an audit row per document
For each file, record:
- source path;
- output path;
- start and completion time;
- success, skipped or failed status;
- safe error message;
- flow version or replacement rule.
Do not put confidential document contents into the log.
Attended versus unattended runs
Power Automate Desktop licensing and machine requirements differ for attended and unattended execution. Check the current licensing documentation and target-machine configuration before describing a flow as unattended.
An unattended run also needs a predictable desktop session, access to the files, Word installed where required and a recovery route for dialogs. Building the steps does not prove that the machine can run them unattended.
Validate the output
After the test run:
- compare file counts;
- open every test output;
- search for the old and new text;
- check headers, footers, fields and layout;
- confirm the originals are unchanged;
- test a rerun.
Scale in small batches. Stop when the error rate or document variation shows that the rule is not universal.
Microsoft sources
- Power Automate Desktop Word actions
- Desktop flow licensing and runtime checks
- Power Automate desktop flow overview
Check the batch and recovery design
Bring the sample set, replacement rule and failure log to the Power Automate Builders Space.
