Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-09-2022, 08:30 AM
valentinator valentinator is offline Never-ending loop Windows 10 Never-ending loop Office 2019
Novice
Never-ending loop
 
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
 

Tags
loop, macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Never-ending loop Number series ending 50 and 100 Marcia Excel 4 08-11-2021 02:36 PM
Never-ending loop Trying to count the number of cells ending with 001 or 002 mgroessl Excel Programming 5 08-06-2019 03:39 PM
Never-ending loop how do you formulate the date by pay period ending? crussell Excel 8 02-23-2016 07:38 AM
Never-ending loop Find and highlight all words ending in -ly RBLampert Word VBA 13 10-23-2012 04:45 PM
Paragraph ending in following page tadlomc Word 1 01-18-2012 05:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:24 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft