Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2021, 04:06 PM
bigjoec bigjoec is offline Add space after every contiguous block of 8-point text Windows 10 Add space after every contiguous block of 8-point text Office 2019
Novice
Add space after every contiguous block of 8-point text
 
Join Date: Sep 2021
Posts: 3
bigjoec is on a distinguished road
Default 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!
Reply With Quote
  #2  
Old 09-16-2021, 05:47 PM
Peterson Peterson is offline Add space after every contiguous block of 8-point text Windows 10 Add space after every contiguous block of 8-point text Office 2019
Competent Performer
 
Join Date: Jan 2017
Posts: 141
Peterson is on a distinguished road
Default

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)
Reply With Quote
  #3  
Old 09-16-2021, 06:39 PM
bigjoec bigjoec is offline Add space after every contiguous block of 8-point text Windows 10 Add space after every contiguous block of 8-point text Office 2019
Novice
Add space after every contiguous block of 8-point text
 
Join Date: Sep 2021
Posts: 3
bigjoec is on a distinguished road
Default

Quote:
Originally Posted by Peterson View Post
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)
Thanks, but unfortunately there are no paragraph marks. It's currently fully embedded in the regular text, just with a different font size.

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"
But the issue is that the body text also includes items of the form "p. ##", mostly references to other documents. So I can't use my find-replace blindly or it will screw up the body text. Fortunately the internal page numbers are distinguished by being in 8 point font (the rest is in 12 point), so I can leverage that in the find-replace.

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.
Reply With Quote
  #4  
Old 09-16-2021, 06:59 PM
Guessed's Avatar
Guessed Guessed is offline Add space after every contiguous block of 8-point text Windows 10 Add space after every contiguous block of 8-point text 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

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
Reply With Quote
  #5  
Old 09-16-2021, 08:48 PM
bigjoec bigjoec is offline Add space after every contiguous block of 8-point text Windows 10 Add space after every contiguous block of 8-point text Office 2019
Novice
Add space after every contiguous block of 8-point text
 
Join Date: Sep 2021
Posts: 3
bigjoec is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
What happens if you leave the find section empty but search for font of 8pt and replace with "^&space"?
Yep, that solved it. Thanks!

I didn't realize there was a way to preserve the found content outside of wildcard search.
Reply With Quote
Reply

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
Add space after every contiguous block of 8-point text 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:36 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