#1
|
|||
|
|||
Add space after every contiguous block of 8-point text
Hi, I have a document with various fonts and point sizes. After every block of 8-point text (which corresponds to page numbers in a janky fake header, fwiw) I need to add a space. For, reasons. Thought I could do this with find/replace, but I don't think it works that way. That is, appears it looks at the formatting AFTER doing the regex matching, and not looking at the format matching and then doing the regex. Or something like that, I'm out of my depth here. There's probably a simple looping approach that can identify blocks of same-formatted text, but I wrote my first Word macro 15 minutes ago and it's not immediately obvious to me. Thanks! |
#2
|
|||
|
|||
If there is a paragraph mark at the end of every instance of a block of 8-point text, and the only attribute you need in order to find the text blocks is the font size, then you could a wildcard find/replace, as follows:
Find: (*)(^13) In the Font section, set the size to 8 points Replace: \1 \2 (To be clear, there's a space between the 1 and the second slash) |
#3
|
|||
|
|||
Quote:
This is step one in reformatting it to get the page numbers out of the text and where they belong. I have the regex to do what I want with the page numbers: Code:
.Text = "(p. )([0-9]{1,4})" .Replacement.Text = "^mPAGE \2^l" However, I'm still not hitting 100% of the cases because there are times where document page number is followed immediately by a number in the body text (e.g. "... they sold p. 175,000 widgets at a price of..."), and Find isn't finding it because the regex is hitting on "p. 175" but that whole string doesn't meet the font size constraint because the 5 is in 12-point font. So I just want to throw in a space after every time the font changes away from 8 points. It will add in a spurious space in some places where I don't want one, but I'm willing to accept that. Once I build in this pre-processing step, my existing macro should cover all cases. |
#4
|
||||
|
||||
What happens if you leave the find section empty but search for font of 8pt and replace with "^&space"?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
Quote:
I didn't realize there was a way to preserve the found content outside of wildcard search. |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to create a block text and when click on the title of block hide and unhide the block | labasritas@free.fr | Word | 4 | 09-17-2017 01:17 PM |
Novice needs: Complicated running totals adding substracting non contiguous cells contiguous columns | innkeeper9 | Excel | 5 | 08-30-2016 04:43 PM |
What is this block of text? | nyempire | Word | 5 | 05-26-2016 06:08 AM |
Too much white space appearing automatically before and after block quotes | amvrword | Word | 2 | 02-16-2016 12:20 PM |
How to "block out" white space in legal documents | Jennifer Murphy | Word | 4 | 05-05-2013 11:17 PM |