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 / Replace text in a Shar...
Power Automate
Suggested Answer

Replace text in a SharePoint File [Word document] using Power Automate

(1) ShareShare
ReportReport
Posted on by 9
Hello Community members,
Any help will be appreciated!
 
I have an issue: I wanted to replace the text in a Word document present in the SharePoint document library. I was getting a file from the SharePoint document library. Get file returns the content in binary data type. I want the content to be in text format so that I can easily replace it.  To convert the binary data output, I used Compose with the expression: @{base64ToString(body('Get_file_content')?['$content'])}. 
Compose 1: @{replace(outputs('Compose'),'Invoice Number','Invoice ID')}
then updating file content content of UPdate File with Compose 1 outputs. but it's not working. not replacing the text. Is there any other way to do!
Please suggest solution for me.
Thank you!
Categories:
I have the same question (0)
  • Fredrik_A Profile Picture
    3,566 Super User 2026 Season 1 on at
    Hello,
     
    in my experience, the only way to do this is by having a word template with Content Controls, that you then fillout using Power Automate with the action "Populate a Microsoft Word Template". But there might be someone on the forums that has another clever solution.
     
    Ill leave a link to the action here: Word Online (Business) - Connectors | Microsoft Learn
     
    Why your flow most likely isn't working:
    base64ToString() assumes the file is plain text, but .docx is a binary format.
    Even if you decode it, the contents of the file are not readable or editable as plain text.
    Replacing text this way can corrupt the file.
     
     
    If my response solved your issue, please mark it as ✅ Accepted Answer and give it a like.
  • Suggested answer
    Community member Profile Picture
    9 on at
    Hello @StretchFredrik
    Can it be achieved using the GRAPH API or the REST API in Power Automate?
    Thank you
  • Suggested answer
    Fredrik_A Profile Picture
    3,566 Super User 2026 Season 1 on at
    Hello,
     
    From my experience, no
    The only solution i know is the one i posted below
     
    If my response solved your issue, please mark it as ✅ Accepted Answer and give it a like.
  • Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at
    Your general approach can work, but it's harder to get to the content:
    First you have to unzip the .docx file, then grap the document.xml.
     
  • Suggested answer
    takolota1 Profile Picture
    4,980 Moderator on at
    If you have access to an Azure account then this template function app contains a Replace Text in Word function
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 557

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 264 Super User 2026 Season 1

Last 30 days Overall leaderboard