Consulting

Results 1 to 4 of 4

Thread: search for specific track change in word

  1. #1

    Unhappy search for specific track change in word

    Hi all,

    actually i'm looking for a macro code to look for a specific text in in word and accept its track change

    ex.

    look for word "Orange" and accept the track change for it.

    i only got a code that can accept all track changes in file


    Private Sub AcceptAllChanges()
    Dim stry As Object


    For Each stry In ActiveDocument.StoryRanges
    If stry.Revisions.Count >= 1 Then _
    stry.Revisions.AcceptAll
    Next
    End Sub


  2. #2
    How about
    Option Explicit
    
    Private Sub Macro1()
    Dim oStory As Range
    Dim oRev As Revision
    Const strFind As String = "Orange" 'Case sensitive
    
        For Each oStory In ActiveDocument.StoryRanges
            If oStory.Revisions.Count >= 1 Then
                For Each oRev In oStory.Revisions
                    If InStr(1, oRev.Range, strFind) > 0 Then
                        oRev.Accept
                    End If
                Next oRev
            End If
            If oStory.StoryType <> wdMainTextStory Then
                While Not (oStory.NextStoryRange Is Nothing)
                    Set oStory = oStory.NextStoryRange
                    If oStory.Revisions.Count >= 1 Then
                        For Each oRev In oStory.Revisions
                            If InStr(1, oRev.Range, strFind) > 0 Then
                                oRev.Accept
                            End If
                        Next oRev
                    End If
                Wend
            End If
        Next
    lbl_Exit:
        Set oStory = Nothing
        Set oRev = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Works great bro, you are awesome 👍👍

    I'm thinking if it is possible to display a msg box to write the wanted text inside it
    Better than doing it inside macro code

    please don't bother yourself if it can't be done

    and thanks again

  4. #4
    Replace the line
    Const strFind As String = "Orange" 'Case sensitive
    with
    Dim strFind As String
        
        strFind = InputBox("Enter the term to find")
        If strFind = "" Then GoTo lbl_Exit
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •