Sub Macro21() Dim MyRange As Word.Range, strText As String Dim myString As String Dim Textrange As Range Set Textrange = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(2).Range.Start, End:=ActiveDocument.Paragraphs(15).Range.End) Set MyRange = Textrange strText = "xlf*;" My: With MyRange.Find .ClearFormatting .Text = strText .MatchWildcards = True Do While .Execute myString = VBA.Replace(MyRange.Text, " ", "") myString = VBA.Mid(myString, 4, Len(myString) - 4) MyRange.Text = "2006" MyRange.SetRange Start:=MyRange.End, End:=Textrange.End GoTo My Loop End With End Sub
或者这样:
Sub Macro21()
Dim Textrange As Range
Set Textrange = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(2).Range.Start, End:=ActiveDocument.Paragraphs(15).Range.End)
With Textrange.Find
.Execute findtext:="xlf*;", MatchWildcards:=True, Forward:=True, _
replacewith:="xlf006;", Replace:=wdReplaceAll
End With
End Sub
参参find的帮助。在VBE中选中find,按F1,详细看一下。体会一下。
[此贴子已经被作者于2006-5-28 14:48:13编辑过] |