|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 提取划线内容()
Dim myDoc As Document, myStr As String, m&
Dim myParRange As Range, n&, resData()
Set myDoc = ActiveDocument
With myDoc.Content.Find
Do While .Execute("[0-9]@[..]", , , -1)
With .Parent
If isStartNum(.Paragraphs(1).Range.Text) Then
Set myParRange = .Paragraphs(1).Range.Duplicate
With .Paragraphs(1).Range.Find
.Font.Underline = wdUnderlineWavy
Do While .Execute
With .Parent
If Not .InRange(myParRange) Then Exit Do
myStr = myStr + vbTab + .Text: n = n + 1
End With
Loop
End With
If n > 0 Then
m = m + 1: ReDim Preserve resData(1 To m): n = 0
resData(m) = .Text + Mid(myStr, 2): myStr = Empty
End If
.Start = .Paragraphs(1).Range.End
Else
.Start = .Paragraphs(1).Range.End
End If
End With
Loop
End With
Documents.Add.Content.Text = Join(resData, vbCr)
End Sub
Function isStartNum(ByVal myStr As String) As Boolean
Dim re As Object
Set re = CreateObject("VBScript.Regexp")
re.Pattern = "^[0-9]+[..]"
isStartNum = re.test(myStr)
End Function
|
评分
-
1
查看全部评分
-
|