|
下面是一段程序。
Sub 段落排序()
Dim mt, oRng As Range, n&, m&, str$, Unm, k()
Dim d, Ydoc As Document, Mdoc As Document
Set Ydoc = ThisDocument
Set d = CreateObject("Scripting.Dictionary")
Set reg = CreateObject("vbscript.regexp")
reg.Global = True: reg.IgnoreCase = False: reg.MultiLine = True
reg.Pattern = "^[((]\s*(\d+)\s*[))](?:(?!^[((]\s*\d+\s*[))]).)+"
str = Replace(Ydoc.Content, Chr(7), "")
For Each mt In reg.Execute(str)
Unm = mt.submatches(0)
m = mt.FirstIndex: n = mt.Length
Set oRng = Ydoc.Range(m, m + n)
Set d(Unm) = oRng
Next
k = d.keys: WordBasic.sortarray k()
Set Mdoc = Documents.Add
For i = 0 To d.Count - 1
With Mdoc.Content
.Collapse 0
.FormattedText = d(CStr(k(i))).FormattedText
End With
Next
End Sub
WordBasic.sortarray k()中的WordBasic到底是什么,是不是指Word VBA呢?
如果是,为什么写作VBA.sortarray是错误的?它跟Word VBA到底是什么关系?
求解惑。 |
|