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

Notifications

Announcements

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)
  • StretchFredrik Profile Picture
    3,395 Super User 2025 Season 2 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
    StretchFredrik Profile Picture
    3,395 Super User 2025 Season 2 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,443 Super User 2025 Season 2 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,974 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard