Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2022, 07:53 PM
jec1 jec1 is offline Clean Up Pasted Text from PDF (hard returns end of lines) Windows 10 Clean Up Pasted Text from PDF (hard returns end of lines) Office 2019
Advanced Beginner
Clean Up Pasted Text from PDF (hard returns end of lines)
 
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, 9 views)
Reply With Quote
  #2  
Old 08-16-2022, 10:53 PM
Guessed's Avatar
Guessed Guessed is offline Clean Up Pasted Text from PDF (hard returns end of lines) Windows 10 Clean Up Pasted Text from PDF (hard returns end of lines) Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

It worked for me.

Are you getting an error? Or just not seeing any change in the active document?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-16-2022, 11:08 PM
jec1 jec1 is offline Clean Up Pasted Text from PDF (hard returns end of lines) Windows 10 Clean Up Pasted Text from PDF (hard returns end of lines) Office 2019
Advanced Beginner
Clean Up Pasted Text from PDF (hard returns end of lines)
 
Join Date: Jan 2012
Posts: 84
jec1 is on a distinguished road
Default Clean Up Pasted Text (hard returns end of lines)

Hi Andrew
No change in active document. I must be missing something.
Reply With Quote
  #4  
Old 08-16-2022, 11:10 PM
macropod's Avatar
macropod macropod is offline Clean Up Pasted Text from PDF (hard returns end of lines) Windows 10 Clean Up Pasted Text from PDF (hard returns end of lines) Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Works for me on your sample document...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 08-16-2022, 11:21 PM
jec1 jec1 is offline Clean Up Pasted Text from PDF (hard returns end of lines) Windows 10 Clean Up Pasted Text from PDF (hard returns end of lines) Office 2019
Advanced Beginner
Clean Up Pasted Text from PDF (hard returns end of lines)
 
Join Date: Jan 2012
Posts: 84
jec1 is on a distinguished road
Default Clean Up Pasted Text (hard returns end of lines)

Hi Macropod and Andrew

I just downloaded the document I uploaded and ran the macro again.
It worked.

Thank you both for looking at this.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clean Up Pasted Text from PDF (hard returns end of lines) How to release hard returns? markg2 Word 13 05-08-2023 01:38 PM
Remove only some hard returns falcios Word 4 05-11-2021 07:02 PM
Clean Up Pasted Text from PDF (hard returns end of lines) Returns in Word table text become multiple rows when pasted in Excel blorence Word Tables 8 01-23-2019 01:57 PM
Unwanted Hard Returns when using Heading Styles alfondacaro Word 3 11-27-2013 07:46 AM
hard lines across document - can't remove joanieS Word 3 07-30-2013 11:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft