R
Raj
Hi,
When I run the following sub from Word, it highlights all the instance
of the input string. However, when word is invoked from excel, a word
document opened and the sub is called, the word "find" is highlighted
and "Argument not optional" error appears.
Sub HighlightWord()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
rspFind = InputBox("Input the string for highlighting")
With rDcm.Find
.Text = rspFind
While .Execute
rDcm.HighlightColorIndex = wdYellow
Wend
End With
End Sub
Please help. Thanks in Advance.
When I run the following sub from Word, it highlights all the instance
of the input string. However, when word is invoked from excel, a word
document opened and the sub is called, the word "find" is highlighted
and "Argument not optional" error appears.
Sub HighlightWord()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
rspFind = InputBox("Input the string for highlighting")
With rDcm.Find
.Text = rspFind
While .Execute
rDcm.HighlightColorIndex = wdYellow
Wend
End With
End Sub
Please help. Thanks in Advance.