|
试做了一下,有点复杂:- Sub test()
- Dim a() As String, i As Integer
- Dim aa() As String, c As Integer, n As Integer
- Dim TF As Boolean, s As Long
- Application.ScreenUpdating = False
- With ActiveDocument.Content.Find
- '搜集答案信息部分
- .Text = "填空题"
- .Forward = False
- .MatchWildcards = True
- If .Execute Then .Forward = True
- .Text = "^13[0-9]@.[!^13]{1,}"
- .Parent.Collapse wdCollapseEnd
- Do While .Execute
- ReDim Preserve a(i)
- a(i) = .Parent.Text
- a(i) = Trim(Mid(a(i), InStr(a(i), ".") + 1))
- i = i + 1
- If i > 60 Then Exit Do '填空题共有61题
- Loop
- .Parent.Collapse wdCollapseEnd
- Do While .Execute("[0-9]@.[∨×]")
- ReDim Preserve a(i)
- a(i) = .Parent.Text
- a(i) = Trim(Mid(a(i), InStr(a(i), ".") + 1))
- i = i + 1
- Loop
- .Parent.Collapse wdCollapseEnd
- Do While .Execute("[0-9]@.[A-F]{1,}")
- ReDim Preserve a(i)
- a(i) = .Parent.Text
- a(i) = Trim(Mid(a(i), InStr(a(i), ".") + 1))
- i = i + 1
- Loop
-
- '定位填写答案部分
- .Parent.WholeStory
- i = 0
- .Text = ""
- .Font.Underline = wdUnderlineSingle
- .Format = True
- Do While .Execute
- If .Parent.Text <> Chr(13) Then
- If TF = False Then
- aa = Split(a(i), Chr(32))
- TF = True
- End If
- For n = c To UBound(aa)
- c = c + 1
- If aa(n) <> Empty Then
- .Parent.Text = Chr(32) & aa(n) & Chr(32)
- If n = UBound(aa) Then
- i = i + 1
- c = 0
- TF = False
- End If
- Exit For
- End If
- Next
- End If
- .Parent.Collapse wdCollapseEnd
- Loop
- .Format = False
- .Text = "(^32{4,})"
- Do While .Execute
- With .Parent '一道选择题如有两个以上括号,答案只在第一个括号内
- If .Paragraphs.First.Range.Start > s Then
- .SetRange .Start + 2, .End - 2
- .Text = a(i)
- s = .Paragraphs.First.Range.Start
- i = i + 1
- End If
- .Collapse wdCollapseEnd
- End With
- Loop
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|