search and replace

B

bilisa

Does anybody know how to search and replace inside a textbox in a Word
document with VBA? Something like this

Set myRange = ActiveDocument.Range(Start:=0, End:=0)
With myRange.Find
.ClearFormatting
.Text = "hello"
With .Replacement
.ClearFormatting
.Text = hello.Value 'a textbox value from a userform
End With
.Execute Replace:=wdReplaceAll, _
Format:=True, MatchCase:=True, _
MatchWholeWord:=True
End With
 

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