|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 duquancai 于 2017-8-22 08:13 编辑
Sub 给题和题枝干加别加题号编号()
Dim mts As Object, reg As Object, doc As Document, a
Set doc = ActiveDocument: Set reg = CreateObject("vbscript.regexp")
reg.Global = True: reg.MultiLine = True
reg.Pattern = "^[^\r]*\(\)(?:(?!^[^\r]*\(\)).)+"
a = Array("A、", "B、", "C、", "D、", "E、", "F、", "G、", "H、")
doc.Content.Find.Execute "^w^p", , , , , , , , , "^p", 2
doc.Content.Find.Execute "^13{2,}", , , 1, , , , , , "^p", 2
Set mts = reg.Execute(doc.Content.Text)
If Not mts Is Nothing Then
For j = mts.Count - 1 To 0 Step -1
m = mts(j).FirstIndex: n = mts(j).Length
With doc.Range(m, m + n)
.Paragraphs(1).Range.InsertBefore j + 1 & "."
If .Paragraphs.Count <= UBound(a) Then
For i = 2 To .Paragraphs.Count
.Paragraphs(i).Range.InsertBefore a(i - 2)
Next
End If
End With
Next
End If
End Sub
|
评分
-
1
查看全部评分
-
|