View Single Post
 
Old 01-03-2025, 10:24 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 294
vivka is on a distinguished road
Default

You are welcome, Robnun! Two remarks if you don't mind: 1) I've deleted one unneeded line in the code in Post 3; 2) I think the following code that uses the Macropod's idea is better for your case:
Code:
Sub FindReplaceAll_2()

Dim RngTxt As range
    Selection.Collapse Direction:=wdCollapseStart
    Set RngTxt = Selection.range
    Selection.PasteSpecial DataType:=wdPasteText
    RngTxt.End = Selection.range.End
    RngTxt.Select
        With Selection.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .text = "[<>#]"
            .Replacement.text = "-"
            .Forward = True
            .Wrap = wdFindStop
            .MatchWildcards = True
            .Execute Replace:=wdReplaceAll
        End With
    Selection.Copy
End Sub
Reply With Quote