|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
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
查看全部评分
-
|