|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub TEST()
Dim strPath$, br(), i&, r&, n&, regEx As Object, Par As Paragraph
Application.ScreenUpdating = False
strPath = ThisDocument.Path & "\"
Set regEx = CreateObject("VBScript.RegExp")
regEx.Pattern = "^[0-9]+\.[A-Z]+"
With Documents.Add
With ThisDocument
.Range(.Content.Start, .Content.End - 1).Copy
End With
.Range(0).Paste
For Each Par In .Paragraphs
If regEx.TEST(Par.Range.Text) Then
n = Len(regEx.Execute(Par.Range.Text)(0))
r = r + 1
ReDim Preserve br(1 To r)
Set br(r) = .Range(Par.Range.Start + n, Par.Range.Start + n)
End If
Next
For i = 1 To UBound(br)
br(i).InsertAfter vbCr & "解析:"
Next i
.SaveAs strPath & "结果"
.Close
End With
Application.ScreenUpdating = True
Beep
End Sub
|
|