View Single Post
 
Old 03-20-2024, 09:35 AM
Jakov93 Jakov93 is offline Windows 10 Office 2010
Advanced Beginner
 
Join Date: Jul 2021
Posts: 45
Jakov93 is on a distinguished road
Default Remove hyphenation from copied text from pdf in Word VBA

Hi,
When I copy text from pdf, many hyphenation appear, I tried many search condition to look for "- " but all failed
The only way which recognize that is when I type "^?‑ "
So it require any character dash space
Now I want to keep the character and remove dash space
I used ^? again in replace box but it's not valid

Any modification to such macro
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 = ""
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = False
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Thanks
Reply With Quote