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
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