Solved: Need help regarding formatting sting using VBA
I'm currently using a macro/VBA to find and replace string in word document from excel data.
This code is working fine for me.
[VBA]
Dim xlApp 'As Excel.Application
Dim xlWB 'As Excel.Workbook
Dim idx As Integer
Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open("C:\Desktop\Replacelist.xlsx")
For idx = 1 To 500
'MsgBox "Replacing " & xlWB.Worksheets(1).Cells(idx, 1) & " by " & xlWB.Worksheets(1).Cells(idx, 2)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = xlWB.Worksheets(1).Cells(idx, 1)
.Replacement.Text = xlWB.Worksheets(1).Cells(idx, 2)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next
xlWB.Close False
xlApp.Quit
Set xlWB = Nothing
Set xlApp = Nothing
[/VBA]
But i want the replaced string to be formatted with Red color font, Italics and underlined.
Can anyone please :help me on this.
Thanks in advance.