Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-22-2015, 09:05 PM
RickLegrand RickLegrand is offline Replace a random character with the same character Windows 8 Replace a random character with the same character Office 2013
Novice
Replace a random character with the same character
 
Join Date: Jul 2015
Location: São Paulo, Brazil
Posts: 4
RickLegrand is on a distinguished road
Default Replace a random character with the same character

When converting PDF files it keeps lots of broken lines, like in this example:


"Two are of intragalactic origin. They derive from planets whose§
d
esignations by extension of the present star identification system are Alpha Centauri A 4, Boötes—"



As seen, most times it is a Paragraph Return (§) followed by a small caps letter.

I could find the Paragraph Mark and random small caps letters using the Wildcard ^p[a-z], but I found no way to replace the letter with the same one.

Is there a way to find the Paragraph Return+small caps letter and replace the Paragraph Mark with a white space and keeping the same small caps letter?

I am using Ms Word 2013



Thank you in advance for your assistance
Rick
Reply With Quote
  #2  
Old 07-23-2015, 12:59 AM
macropod's Avatar
macropod macropod is offline Replace a random character with the same character Windows 7 64bit Replace a random character with the same character Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

This sort of thing has been asked about many times and there are numerous threads with replies. See, for example: https://www.msofficeforums.com/word/...html#post32907
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-23-2015, 07:51 AM
RickLegrand RickLegrand is offline Replace a random character with the same character Windows 8 Replace a random character with the same character Office 2013
Novice
Replace a random character with the same character
 
Join Date: Jul 2015
Location: São Paulo, Brazil
Posts: 4
RickLegrand is on a distinguished road
Default Replace a random character with the same character

Hi Paul. Thanks for the fast reply.
Sorry, not that. I had already tried that macro, but it cleans all the text, and turns it into a single block.
I need cleaning only the ones marked in red.
I attached an example text here so you can see exactly what I need.
One way I just thought of is a macro going letter by letter for all the alphabet.
But I'm totally illiterate in VBA. If you could give me a macro for letter "a", and instructions on how to do it, I could fill in the rest of the alphabet.

Thanks a lot
Rick
Reply With Quote
  #4  
Old 07-23-2015, 09:43 AM
Robert2 Robert2 is offline Replace a random character with the same character Windows 8 Replace a random character with the same character Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 165
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

You could try your luck with the following wildcard Find/Replace:
Find What: (^13)([a-z])
Replace With: ^32\2
Reply With Quote
  #5  
Old 07-23-2015, 01:59 PM
RickLegrand RickLegrand is offline Replace a random character with the same character Windows 8 Replace a random character with the same character Office 2013
Novice
Replace a random character with the same character
 
Join Date: Jul 2015
Location: São Paulo, Brazil
Posts: 4
RickLegrand is on a distinguished road
Default

Yeah Robert, thats it. Worked beautifully.
I had recorded one doing it letter by letter - hard-working - and it worked very well, too. But yours is much, much simpler.
Now I thought of another good use for it. Books in PDF, when converted to EPUB for an eReader have the same problem with broken lines. This is a great way to clean them, too before converting to EPUB.

Thanks a lot.
Reply With Quote
  #6  
Old 07-23-2015, 05:25 PM
macropod's Avatar
macropod macropod is offline Replace a random character with the same character Windows 7 64bit Replace a random character with the same character Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Quote:
Originally Posted by RickLegrand View Post
Hi Paul. Thanks for the fast reply.
Sorry, not that. I had already tried that macro, but it cleans all the text, and turns it into a single block.
Evidently, then, you hadn't applied the one stricture the post says the code requires - that the text contains two paragraph breaks to differentiate the logical paragraphs from the physical ones.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 07-23-2015, 06:14 PM
RickLegrand RickLegrand is offline Replace a random character with the same character Windows 8 Replace a random character with the same character Office 2013
Novice
Replace a random character with the same character
 
Join Date: Jul 2015
Location: São Paulo, Brazil
Posts: 4
RickLegrand is on a distinguished road
Default

I really don't know, Paul. As I said before, I'm totally illiterate in VBA. Programming is for the young and adventurous ones, I'm too old for learning now. All I know of macros is using them. I was simply copying and trying them as per the instructions from the post you sent. To follow Robert's idea I first tested it and later I used the Record Macro button and executed the procedure by hand. And now the macro works right. Here is the code Word recorded automatically:

Sub CleanUpPDFText2()
'
' CleanUpPDFText2 Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(^13)([a-z])"
.Replacement.Text = "^32\2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

_______________
Cheers
Rick
Reply With Quote
  #8  
Old 07-23-2015, 06:35 PM
macropod's Avatar
macropod macropod is offline Replace a random character with the same character Windows 7 64bit Replace a random character with the same character Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Quote:
Originally Posted by RickLegrand View Post
I really don't know, Paul. As I said before, I'm totally illiterate in VBA. Programming is for the young and adventurous ones, I'm too old for learning now. All I know of macros is using them. I was simply copying and trying them as per the instructions from the post you sent.
And that post says quite clearly:
Quote:
Note that the code assumes there are at least two such paragraph breaks between the 'real' paragraphs.
None of this requires any experience in programming - just following a few instructions.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace a random character with the same character How can select from a specific character to another character mohsen.amiri Word 2 02-19-2015 11:38 PM
Wildcard Find/Replace deletes extra character Cosmo Word 1 06-20-2014 08:49 AM
Replace a random character with the same character Character based Search and Replace font size anacond11 Word 2 08-08-2013 08:10 AM
Is it possible to include a newline character in the replace text desgordon Word 2 09-14-2012 02:28 AM
Replace a random character with the same character Using replace to make a word bold and its proceeding character. bostonboi Word 1 01-16-2011 01:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:59 AM.


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