View Single Post
 
Old 08-16-2022, 07:53 PM
jec1 jec1 is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Jan 2012
Posts: 84
jec1 is on a distinguished road
Default Clean Up Pasted Text from PDF (hard returns end of lines)

Hi, using Macropod's macro - it doesn't seem to work anymore. Any ideas please most welcome.

Code:
Sub CleanUpPastedText()
'Turn Off Screen Updating Macropod
Application.ScreenUpdating = False
Dim StrFR As String, i As Long
'Paired F/R expressions, each separated by |
StrFR = "[ ^s^t]{1,}^13|^p|([!^13^l])([^13^l])([!^13^l])|\1 \3|[^s ]{2,}| |([a-z])-[^s ]{1,}([a-z])|\1\2|[^13^l]{1,}|^p"
'Address any Internationalisation issues
If Application.International(wdListSeparator) = ";" Then
  StrFR = Replace(StrFR, ",", ";")
End If
With ActiveDocument.Range.Find
  .ClearFormatting
  .replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindStop
  .Format = False
  .MatchAllWordForms = False
  .MatchSoundsLike = False
  .MatchWildcards = True
  'Process all F/R expressions
  For i = 0 To UBound(Split(StrFR, "|")) Step 2
    .text = Split(StrFR, "|")(i)
    .replacement.text = Split(StrFR, "|")(i + 1)
    .Execute Replace:=wdReplaceAll
  Next
End With
'Restore Screen Updating
Application.ScreenUpdating = True
End Sub
Attached Files
File Type: docx Clean Up Text pasted from pdf with macro.docx (50.3 KB, 11 views)
Reply With Quote