|
用最低效率的代码来解决问题:
Sub 仅对当前文档有效()
Application.ScreenUpdating = 0
Selection.HomeKey wdStory
Dim dic As Object
Set dic = CreateObject("scripting.dictionary")
With Selection.Find
.MatchWildcards = 1
.Text = "多项选择题答案"
If .Execute Then temend = .Parent.Start
.Parent.HomeKey wdStory
.Text = "[0-9]{1,}\.[A-E]{1,}"
Do While .Execute
If .Parent.End > temend Then .Parent.HomeKey: GoTo aa:
dic(Split(.Parent, ".")(0)) = Split(.Parent, ".")(1)
Loop
End With
aa:
With Selection.Find
Selection.HomeKey wdStory
.MatchWildcards = 1
.Text = "[0-9]{1,}."
Do While .Execute
Selection.MoveDown wdParagraph
Selection.End = Selection.End - 3
n = n + 1
Selection = dic("" & n & "")
.Parent.Collapse 0
Loop
End With
dic.RemoveAll
With Selection.Find
.MatchWildcards = 1
.Text = "多项选择题答案"
If .Execute Then .Parent.EndKey
.Text = "[0-9]{1,}\.[A-E]{1,}"
Do While .Execute
dic(Split(.Parent, ".")(0)) = Split(.Parent, ".")(1)
Loop
End With
n = 0
With Selection.Find
Selection.HomeKey wdStory
.Text = "多项选择题"
If .Execute Then .Parent.EndKey
.MatchWildcards = 1
.Text = "[0-9]{1,}."
Do While .Execute
Selection.MoveDown wdParagraph
Selection.End = Selection.End - 3
n = n + 1
Selection = dic("" & n & "")
.Parent.Collapse 0
Loop
End With
Application.ScreenUpdating = 1
End Sub 【附件仅对当前文档有效】
|
|