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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Attempting to find-and...
Power Automate
Suggested Answer

Attempting to find-and-replace or edit .docx files in a flow?

(1) ShareShare
ReportReport
Posted on by 2
Hi Everyone!

Would it be possible to do a find-and-replace on .docx files in power automate or edit text while still keeping the original formatting? Im attempting to edit 200+ process documents based on certain conditions already built out in power automate, and I want to find a way to find and replace certain words, or find and add certain text beside these words.

I'm unable to use third party connectors such as Encodian, so I wanted to see if it's possible through office scripts, or another method?

Thank you! :) Really appreciate your help.
Categories:
I have the same question (0)
  • Suggested answer
    Valantis Profile Picture
    6,569 on at
     
    Yes, Office Scripts is the right approach here since you can't use Encodian or similar connectors.
     
    Here's the confirmed working pattern:
    1. In Power Automate, get the file from SharePoint/OneDrive using Get file content
     
    2. Pass the file to an Excel Online (Business) action with Run script, using an Office Script to perform the find and replace
     
    3. Save the result back
    Wait though, Office Scripts runs inside Excel, not Word. For Word .docx files specifically, the equivalent is Word Online with a Run script action, but Word Online Office Scripts support is more limited than Excel.
     
    The more reliable approach for .docx without third-party connectors:
     
    1. Use the Word Online (Business) connector action Populate a Microsoft Word template. This replaces placeholder tokens you define in the template with dynamic values. If you can modify your 200 documents to use {{placeholder}} tokens, this is clean and preserves formatting.
     
    2. For true find-and-replace on existing .docx files without modifying the source: use an HTTP action to call the Microsoft Graph API's Word find-and-replace endpoint. Graph supports search and replace operations on Word files stored in SharePoint/OneDrive:
     
     
     
    Actually for Word specifically the confirmed Graph API approach is via the OneDrive/SharePoint File Open Session + the Word REST API.
    Given the 200+ file constraint, what's the nature of the replacements are they the same substitutions across all files, or different per file? That affects which approach is most practical.

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

     
  • JP-09061751-0 Profile Picture
    2 on at
    Hi @Valantis,

    thank you for your quick response! the files themselves are all different, there is no certain template they follow, so the word I am attempting to replace could be in different places depending on the document. So, I don't believe the populating a word template function would be helpful in this case! in terms of using word scripts, what connector/action would be used? I can't seem to find the ones that would be applicable, just ones for excel!

    thank you!
  • Suggested answer
    chiaraalina Profile Picture
    2,370 Super User 2026 Season 1 on at
     
    Office Scripts for Word documents do not exist. They are Excel only (currently).
     
    I recommend to use Power Automate Desktop for this. 
     
    Desktop flows include a built-in action:
    “Find and replace words in Word document”
    This runs via the locally installed Word application (attended or unattended), not via a cloud connector.
     
    Limitation: Not cloud-native; runs on Windows machine
     
    Hope it helps!

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 463

#1
Valantis Profile Picture

Valantis 463

#3
11manish Profile Picture

11manish 264

Last 30 days Overall leaderboard