http://club.excelhome.net/dispbbs.asp?boardid=23&replyid=636185&id=207360&page=1&skin=0&Star=2 在学习兄帖子“制作改错题的最佳办法是什么”后,在守版主等高手代码的基础上添加了一小段代码,进行批量替换英文改错题选项,但运行速度慢了些,请帮忙解决 实例如下: 46. The professor told the economics [A] student that he didn’t approve in [C] his taking the advanced course before [D] he made a passing mark in Economics Sub 批量替换英文改错题选项() '将位于带下划线改错题右边的[A]、、[C]、[D]替换到下改错题的正下方 Dim myRange As Range, EqA As String, EqB As String Dim lngStart As Long, lngEnd As Long, myField As Field On Error Resume Next Application.ScreenUpdating = False NF: If myRange Is Nothing Then Set myRange = ActiveDocument.Content Else myRange.SetRange myRange.End, ActiveDocument.Content.End - 1 End If With myRange.Find .ClearFormatting .Format = True .Font.Underline = True Do While .Execute With myRange lngStart = .Start EqA = .Text .SetRange .End, .End + 4 lngEnd = .End EqB = .Text .SetRange lngStart, lngEnd .Delete Set myField = .Fields.Add(myRange, wdFieldEmpty, "ADVANCE \u 8 ", False) Set myField = .Fields.Add(myRange, wdFieldEmpty, "EQ \F(" & EqA & "," & EqB & ")", False) Set myField = .Fields.Add(myRange, wdFieldEmpty, "ADVANCE \d 8 ", False) myField.ShowCodes = False myField.Update GoTo NF End With Loop Application.ScreenUpdating = True End With With Selection.Find ActiveWindow.View.ShowFieldCodes = True .ClearFormatting .Replacement.ClearFormatting .MatchWildcards = True '勾选“使用通配符” .Text = "\[([ABCD])\]" .Execute replacewith:="\1^32", Replace:=wdReplaceAll ActiveWindow.View.ShowFieldCodes = False Selection.Fields.Update End With End Sub
[此贴子已经被作者于2008-6-12 13:07:55编辑过] |