replacing values using variable name

D

Daniel

I am having trouble with using string variable name instead of "hello"
replacement.text. I am getting type mismatch when I pass it from htm file to
ocx. Any help would be appreciated.

Thanks
Daniel

With Selection.Find
.ClearFormatting
.Text = "hi"
.Replacement.ClearFormatting
.Replacement.Text = "hello"
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
 
J

Jezebel

Dim pString as string

pString = "Goodbye"


With Selection.Find
.ClearFormatting
.Text = "hi"
.Replacement.ClearFormatting
.Replacement.Text = pString
.Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
 
D

Daniel

That is what I did. And somehow I was getting type mismatch error. I changed
to ByVal rString As String, then the message disappeared. But somehow, the
text is not replaced. It finds and highlights it, but does not replace. I am
not sure why.

Thanks
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top