VBA Word将格式化文本转换为曲目更改

VBA Word将格式化文本转换为曲目更改,vba,ms-word,Vba,Ms Word,我需要将具有虚假轨迹更改的文档还原为真实轨迹更改 我已经写了这段代码,但它会大大降低应用程序的速度,并且Word会挂起。有更好的选择吗 Sub FormattingToTC() 'Main procedure for the transformation of track changes Dim rev As Revision Dim sect As Section Dim selAccepted As Selection Dim selDel As Se

我需要将具有虚假轨迹更改的文档还原为真实轨迹更改

我已经写了这段代码,但它会大大降低应用程序的速度,并且Word会挂起。有更好的选择吗

Sub FormattingToTC()
    'Main procedure for the transformation of track changes
    Dim rev As Revision
    Dim sect As Section
    Dim selAccepted As Selection
    Dim selDel As Selection
    Dim storyRange As Range
    Dim strFullName As String, strName As String, strOldFullName As String
    Dim strPath As String
    Dim OriginalDoc As Document

    Application.DisplayAlerts = wdAlertsNone
    ActiveDocument.TrackFormatting = False
    ActiveDocument.TrackRevisions = False


    Selection.Find.ClearFormatting
    Selection.Find.Font.StrikeThrough = True  'Find all strikethrough text
    With Selection.Find
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
    End With

    Do While Selection.Find.Execute = True  'All matches are deleted with tracked changes active
        ActiveDocument.TrackRevisions = True
        Selection.Delete
    Loop
    Selection.Find.ClearFormatting
    Selection.Find.Highlight = True  'Find all hihglighted text
    With Selection.Find
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True

    End With

    Do While Selection.Find.Execute = True  'All matches are deleted with tracked changes active
        ActiveDocument.TrackRevisions = False
        Selection.Copy
        Selection.Delete
        ActiveDocument.TrackRevisions = True
        Selection.paste
    Loop
    Application.DisplayAlerts = wdAlertsAll
end sub

这只是删除的一部分。还有另一种方法可以避免这种循环吗?例如,使用“查找并替换?”

如果您的代码有效,那么最好继续询问。您所说的“Word挂起”是什么意思?请准确描述一下。您可以尝试两件事:1)使用范围而不是选择对象;2) 使用REPLACE进行测试(作为用户,查看它是否按照您想要的方式工作),并将REPLACE框留空。这将用零替换找到的术语(删除它)。。。