|
Option Explicit
Sub test4()
Dim a, ar(), r&, i&, rngContent As Range, aMatch As Object, Rng As Range, m&, n&
ActiveDocument.ConvertNumbersToText
Set rngContent = ActiveDocument.Content
With CreateObject("VBScript.RegExp")
.Pattern = "\d+\."
.Global = True
For Each aMatch In .Execute(rngContent.Text)
m = aMatch.FirstIndex: n = aMatch.Length
Set Rng = ActiveDocument.Range(rngContent.Start + m, rngContent.Start + m + n - 1)
If IsNumeric(Rng.Text) Then
r = r + 1
ReDim Preserve ar(1 To r)
Set ar(r) = Rng
End If
Next
End With
For i = 1 To UBound(ar)
ar(i).Text = i
Next i
End Sub |
评分
-
1
查看全部评分
-
|