user7755666
user7755666

Reputation:

Selection and modifying inside Shape word

I created A macro to select a specific shape and select Text inside him and look for a specific word and change it but It keep showing me an error for selection.find this is my code

wrdDoc.Shapes("Groupe 643").Select
wrdDoc.Shapes("Groupe 643").GroupItems("Text 
Box644").TextFrame.TextRange.Select
With Selection.Find
  .Text = "Frame FME"
  .Replacement.Text = Sheets("Generate").Range("B67")
 .Forward = True
 .ClearFormatting
 .Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll

Any suggestions Thank you in advance

Upvotes: 0

Views: 2898

Answers (1)

Variatus
Variatus

Reputation: 14373

You shouldn't try to use the Selection object at all. Instead, you can get at the Text in the shape and use the Replace function to modify it.

With ActiveDocument.Shapes(1).TextFrame.TextRange
    Debug.Print .Text
    .Text = Replace(.Text, "text", "new text")
    Debug.Print .Text
End With

Upvotes: 1

Related Questions