* 楼主,你好!——第一,请注意备份原文件(未处理的);第二,如果你的系统是 Win10x64(64位),请复制代码到空白文档后,再剪切下来,粘贴到 VBE 中执行。另外,建议可以把试卷页边距减小一些,让栏间距大一些,更好看(建议试卷要逐题审核,以免有错误之处)。
- Sub a_find_replace_answer_update0109()
- With ActiveDocument.Content.Find
- .Execute "([B-F])( )([! ]*^13)", , , 1, , , , , , "^t\1. \3", 2
- .Execute "([B-F])( )([! ]*^13)", , , 1, , , , , , "^t\1. \3", 2
- .Execute "([B-F])( )([! ]*^13)", , , 1, , , , , , "^t\1. \3", 2
- .Execute "([B-F])( )([! ]*^13)", , , 1, , , , , , "^t\1. \3", 2
- .Execute "([B-F])( )([! ]*^13)", , , 1, , , , , , "^t\1. \3", 2
- .Execute "(A)( )([! ]*^13)", , , 1, , , , , , "\1. \3", 2
- .Execute "(^13)(^t[B-F].)", , , 1, , , , , , "\2", 2
- .Execute "(^t)(D.)", , , 1, , , , , , "^13\2", 2
- .Execute "(答案):", , , 1, , , , , , "\1:", 2
- .Execute "([A-F])(,)([B-F])", , , 1, , , , , , "\1\2 \3", 2
- .Execute "([A-F])(,)([B-F])", , , 1, , , , , , "\1\2 \3", 2
- .Execute "([A-F])(、)([B-F])", , , 1, , , , , , "\1, \3", 2
- .Execute "([A-F])(、)([B-F])", , , 1, , , , , , "\1, \3", 2
- .Execute "(^13)([0-9]{1,})([. ]{1,})", , , 1, , , , , , "\1\1\2. ", 2
- End With
-
- With Selection
- .WholeStory
- With .Font
- .NameFarEast = "宋体"
- .NameAscii = "Times New Roman"
- End With
- .ParagraphFormat.TabStops.ClearAll
- ActiveDocument.DefaultTabStop = CentimetersToPoints(4.6)
- .ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(2.3) _
- , Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
- .HomeKey 6
- End With
-
- Dim i As Paragraph
- For Each i In ActiveDocument.Paragraphs
- With i.Range
- If .Text Like "答案:*" Then
- ActiveDocument.Range(Start:=.Start, End:=.Characters(3).End).Bold = True '答案加粗
- If .End <> ActiveDocument.Content.End Then
- With .Next(4, 1)
- If Asc(.Text) <> 13 Then
- .InsertBefore Text:="解析:"
- ActiveDocument.Range(Start:=.Start, End:=.Characters(3).End).Bold = True '解析加粗
- End If
- End With
-
- End If
- End If
- End With
- Next
- End Sub
复制代码 |