#1
|
|||
|
|||
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§ designations 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 |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
You could try your luck with the following wildcard Find/Replace:
Find What: (^13)([a-z]) Replace With: ^32\2 |
#5
|
|||
|
|||
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. |
#6
|
||||
|
||||
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] |
#7
|
|||
|
|||
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 |
#8
|
||||
|
||||
Quote:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
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 |
Using replace to make a word bold and its proceeding character. | bostonboi | Word | 1 | 01-16-2011 01:54 PM |