Hi All,
I have been trying to write a Word VBA Macro Code which can Search and Replace the text in AutoShapes in a word document.
I have been able to do the same with Excel, however have been unsuccessful in doing so for the Word documents.
Please can someone help me in doing this.
Thanks in advance,
Lonely
***********The Excel Code is *************
Sub Test1()
Dim Sh As Shape
Dim ShRng As ShapeRange
Dim SubSh As Shape
On Error Resume Next
For Each Sh In Worksheets("Sheet1").Shapes
Set ShRng = Sh.Ungroup
If Err = 0 Then
For Each SubSh In ShRng
SubSh.TextFrame.Characters.Text = Replace(SubSh.TextFrame.Characters.Text, "XXX", "YYY")
Next SubSh
ShRng.Regroup
Else
Err.Clear
Sh.TextFrame.Characters.Text = Replace(Sh.TextFrame.Characters.Text, "XXX", "YYY")
End If
Next Sh
End Sub
*************End Code**************




Reply With Quote