View Single Post
 
Old 03-18-2019, 05:09 AM
Asuryan33 Asuryan33 is offline Windows 10 Office 2016
Novice
 
Join Date: Oct 2017
Posts: 9
Asuryan33 is on a distinguished road
Default

Hello.

I have a last question.

I see the macro and ... what is beween the first With Selection.Find // End With.. could be moved to the code you added (I tried and it works same)

Also, if I track modification on word, I see that the macro highlight the word first, then erase it and replace it with non highlight word.
If the change tracking is not activated, I see highlited word as final result.

It's not a big deal, since a can desactivate the tracking before the macro. But I'm curious to know why it's like that.

Code:
   With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Highlight = True
        .Replacement.Text = "^&"
        .Forward = True
        .Format = True
        .MatchWholeWord = True
        .MatchCase = True
        .MatchWildcards = False
    End With

    For i = 1 To docRef.Paragraphs.Count
        Set oPara = docRef.Paragraphs(i).Range
        oPara.End = oPara.End - 1
        With Selection.Find
            .Wrap = wdFindContinue
            .Text = oPara.Text
            .Execute Replace:=wdReplaceAll
        End With
    Next i

Last edited by Asuryan33; 03-18-2019 at 10:28 AM. Reason: More information
Reply With Quote