* 唐兄:新年快乐!
- Sub delNonChn()
- Dim r As Range, s As Range, i&, n&
- With Selection
- If .Type = wdSelectionIP Then
- Set r = ActiveDocument.Content
- Else
- Set r = .Range
- Set s = .Range
- i = 1
- End If
- End With
- With r.Find
- .ClearFormatting
- .Text = "^9[A-Za-z.]{1,}"
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- n = n + 1
- .MoveStart
- .Text = Empty
- With ActiveDocument.Range(Start:=.Start, End:=.Paragraphs(1).Range.End)
- .Find.Execute "[A-Za-z.]{1,}", , , 1, , , , , , ";", 2
- End With
- If i = 1 Then .SetRange Start:=.End, End:=s.End
- End With
- Loop
- End With
- MsgBox "共找到 " & n & " 个!", 0 + 48
- End Sub
复制代码 |