View Single Post
 
Old 03-20-2024, 01:30 PM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 228
vivka is on a distinguished road
Default

Strange, because for me it works smoothly on your sample.
Try the full code:
Code:
Sub RemoveDashSpace()
    Dim oRng   As range
    If Len(selection.range) = 0 Then
        MsgBox "Select the text first", vbCritical
        Exit Sub
    End If
    Set oRng = selection.range
    
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = Chr(30) & Chr(32)
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Reply With Quote