How to change some text into text frame?


A

avkokin

Hello.
There is one document which has some text and 3 text box. All the text
box has identical text (one two three). I need to change all texts in
all the text box. I tried did it with next macro (below), but it
nothing change. Why?
Thank you very much.

Sub findTextFrame()
Dim rng As Range
Dim sh As Shape
Dim str As String
str = "one two three"

For Each sh In ActiveDocument.Shapes
With sh.TextFrame
If .HasText <> 0 Then
Set rng = .TextRange
With rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = str
.Replacement.Text = "New text into text box"
.Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.Execute wdReplaceAll
End With
End If
End With
Next sh

End Sub
 
Ad

Advertisements

H

Helmut Weber

Hi Anton,

not
.Execute wdReplaceAll

but
.Execute Replace:=wdReplaceAll

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
Ad

Advertisements


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