|
先试代码的前半部分- Sub GetAnswer()
- Dim TF As Boolean, a As String, b As String, c As String, d As String
- Dim txt As String, i1 As Integer, i2 As Integer, i3 As Integer, i4 As Integer
- Dim n As Integer, s As Long, info As String
- Application.ScreenUpdating = False
- '提取答案内容
- If MsgBox("提取答案时是否同时删除试题中的答案文本?", vbYesNo) = vbYes Then TF = True
- With ActiveDocument.Content.Find
- .Font.Underline = wdUnderlineSingle
- .Format = True
- Do While .Execute
- With .Parent
- If Val(.Paragraphs.First.Range.Text) > n Or Val(.Previous(wdParagraph).Text) > n Then
- n = Val(IIf(Val(.Paragraphs.First.Range.Text) > n, .Paragraphs.First.Range.Text, .Previous(wdParagraph).Text))
- If .Text <> Chr(13) Then a = a & vbCrLf & n & "." & Trim(.Text)
- ElseIf .Text <> Chr(13) Then
- a = a & Space(4) & Trim(.Text)
- End If
- If TF = True And .Text Like "*[!" & Chr(13) & Chr(32) & "]*" Then .Text = Space(Len(.Text))
- .Collapse wdCollapseEnd
- End With
- Loop
- .Parent.WholeStory
- .Format = False
- .Text = "([^32∨×A-F]@)"
- .MatchWildcards = True
- Do While .Execute
- With .Parent '一道选择题如有两个以上括号,答案只在第一个括号内
- .SetRange .Start + 2, .End - 2
- txt = Trim(.Text)
- If .Paragraphs.First.Range.Start > s And Len(Trim(.Text)) > 0 Then
- If txt Like "[∨×]" Then
- i2 = i2 + 1
- b = b & i2 & "." & txt & IIf(i2 Mod 5 > 0, vbTab, vbCrLf)
- ElseIf txt Like "[A-F]" Then
- i3 = i3 + 1
- c = c & i3 & "." & txt & IIf(i3 Mod 5 > 0, vbTab, vbCrLf)
- ElseIf Len(txt) > 1 Then
- i4 = i4 + 1
- d = d & i4 & "." & txt & IIf(i4 Mod 5 > 0, vbTab, vbCrLf)
- End If
- If TF = True Then .Text = Space(IIf(Len(txt) = 1, 2, 6))
- End If
- s = .Paragraphs.First.Range.Start
- .Collapse wdCollapseEnd
- End With
- Loop
- End With
复制代码 |
评分
-
1
查看全部评分
-
|