Replace specific text from word document


I want to replace the highlighted fields from word document with some some other data. plzz help me out to find a way

Hi @sarvesh.b ,

Can you confirm Particulars and Amount will be the same. which you marked red color.


Yess, that will be same for all the formats.


Did you try this


yess, this is for replace but first i need to get the highlighted texts and then replace with this activity. how do i will get that text field that is the main task.


What does that mean?

May I know on what basis you identify those values manually?


Hi @sarvesh.b
For your specific case, try the VB script code below.

Imports Microsoft.Office.Interop.Word

Open the document file.
Dim app As New Application()
Dim doc As Document = app.Documents.Open(“C:\MyDocument.docx”)

Loop through the tables in the document.
For Each tbl As Table In doc.Tables
Loop through the rows in the table.
For Each row As Row In tbl.Rows
Loop through the cells in the row.
For Each cell As Cell In row.Cells
Replace the value in the cell with a new value.
cell.Range.Text = cell.Range.Text.Replace(“oldValue”, “newValue”)

Save the document and close the application.