【发布时间】:2020-08-27 21:35:17
【问题描述】:
我尝试了这两种方法。一个工作正常,但另一个没有。有人解释原因吗?
1- 这个有效
Dim scount As Integer
Dim x As Integer
scount = WordDoc.Shapes.Count
For x = 1 To scount
WordDoc.Shapes(x).Select
If WordDoc.Shapes(x).TextFrame.HasText = True Then
With WordDoc.Shapes(x).TextFrame.TextRange.Find
.Text = "World"
.Replacement.Text = "505"
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End If
Next x
2- 这个没用
Dim Shp As Shape
For Each Shp In ActiveDocument.Shapes
Shp.Select
With Selection.Find
.Text = "World"
.Replacement.Text = "Here"
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Next
【问题讨论】:
标签: vba replace ms-word textbox