View Single Post
 
Old 06-09-2022, 08:30 AM
valentinator valentinator is offline Windows 10 Office 2019
Novice
 
Join Date: Jun 2022
Posts: 9
valentinator is on a distinguished road
Unhappy Never-ending loop

Hello! I have this macro that I made for a project. It searches for a image and rejects TC changes twice. The problem I have with it is that I can't make it stop at the end of the document so it continues looping until it starts rejecting changes in the text as well. Anybody know how to make it stop at the end of the document?
Thank you in advance!

Code:
Sub Huh()
'
' Huh Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Do
        With Selection.Find
            .Text = "^g"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute
        Selection.Range.Revisions.RejectAll
        Selection.NextRevision (True)
        Selection.Range.Revisions.RejectAll
        Selection.NextRevision (True)
    Loop
End Sub

Last edited by valentinator; 06-09-2022 at 12:33 PM.
Reply With Quote