Hi,
i want to replace the text in word with the text from excel, i am using the below code,but it is not working that is it is not replacing the text.
i want to replace with the current active cell row, of column 6
Sub ClientName()
Dim pathh As String
Dim pathhi As String
Dim oCell As Integer
Dim WA As Object
pathh = "C:\Templates\test.docx"
Set WA = CreateObject("Word.Application")
WA.Documents.Open (pathh)
WA.Visible = True
WA.Selection.Find.ClearFormatting
WA.Selection.Find.Replacement.ClearFormatting
With WA.Selection.Find
.Text = "abc"
.Replacement.Text = Cells(Application.ActiveCell.Row, 6).Value
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
WA.Selection.Find.Execute Replace:=wdReplaceAll
End Sub
please suggest
i want to replace the text in word with the text from excel, i am using the below code,but it is not working that is it is not replacing the text.
i want to replace with the current active cell row, of column 6
Sub ClientName()
Dim pathh As String
Dim pathhi As String
Dim oCell As Integer
Dim WA As Object
pathh = "C:\Templates\test.docx"
Set WA = CreateObject("Word.Application")
WA.Documents.Open (pathh)
WA.Visible = True
WA.Selection.Find.ClearFormatting
WA.Selection.Find.Replacement.ClearFormatting
With WA.Selection.Find
.Text = "abc"
.Replacement.Text = Cells(Application.ActiveCell.Row, 6).Value
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
WA.Selection.Find.Execute Replace:=wdReplaceAll
End Sub
please suggest