MS Word macro: empty lines font size
Thread poster: DZiW (X)
DZiW (X)
DZiW (X)
Ukraine
English to Russian
+ ...
May 29, 2015

Dear colleagues,

I know there're a couple of smart VBA coders here, so I would like to ask you how to cope with such a nuisance:
There's a rather long .DOC which consists of short paragraphs/blocks like
- - - - - - - - - - - - - - - - - - - - - - - -
aaaaaaaaa
*bbbbbbbbbbb
*cccccccccccccccc
*ddddddddd

eeeeeeee
*fffffffffff
*gggggggggggg

hhhhhhhhhhhh
*iiiiiiiiiiiii
*jjjjjjjjjjjjjj
*kkkkkkkkk
... See more
Dear colleagues,

I know there're a couple of smart VBA coders here, so I would like to ask you how to cope with such a nuisance:
There's a rather long .DOC which consists of short paragraphs/blocks like
- - - - - - - - - - - - - - - - - - - - - - - -
aaaaaaaaa
*bbbbbbbbbbb
*cccccccccccccccc
*ddddddddd

eeeeeeee
*fffffffffff
*gggggggggggg

hhhhhhhhhhhh
*iiiiiiiiiiiii
*jjjjjjjjjjjjjj
*kkkkkkkkk
*lllllllll
- - - - - - - - - - - - - - - - - - - - - - - -
The problem is there're far too many whitespaces between the blocks, so I would like to learn how one can change the empty lines font size to, say, 6 or something.

Shortly, I would like to reformat each empty line to be smaller.


TY
Collapse


 
Philip Lees
Philip Lees  Identity Verified
Greece
Local time: 11:16
Greek to English
Just do a search and replace May 30, 2015

DZiW wrote:

The problem is there're far too many whitespaces between the blocks, so I would like to learn how one can change the empty lines font size to, say, 6 or something.

Shortly, I would like to reformat each empty line to be smaller.


TY


Can't you just do a search and replace on repeated new lines:

Find: ^p^p

Replace with: (leave text blank) Font size 6.

That seems to work for me. You may need to tweak it a bit.


 
Dan Lucas
Dan Lucas  Identity Verified
United Kingdom
Local time: 09:16
Member (2014)
Japanese to English
Take a closer look at search and replace May 30, 2015

DZiW wrote:
The problem is there're far too many whitespaces between the blocks, so I would like to learn how one can change the empty lines font size to, say, 6 or something.
Shortly, I would like to reformat each empty line to be smaller.

I have written a lot of VBA in my time, but I would agree with Philip: use find and replace unless you have a really complex problem.

Word doesn't have conventional regex functions, but its "use wildcards" option is more powerful than it looks. For example, you can specify "one or more occurrences" using the "@" character, and so on. Be aware, however, that using the wildcards option changes some codes. Philip mentioned "^p" to find a paragraph mark (a hard return), but if you were to use wildcards that would not work: use "^13" instead.

Multiple empty lines are, if you think about it, just sequences of paragraph marks. One way to remove these would be to replace any sequence of more than two paragraph marks with just one paragraph mark.

Try "^13{2,}" in the Find field and "^13" in the Replace field, having first checked the "use wildcards" option. That should remove the empty lines. The "{2,}" specifies that the string being searched for (the one directly before the "{2,}" should be found a minimum of two times. You probably don't want to remove EVERY paragraph mark after all.

If you're interested in how to reproduce this in VBA, you could record a macro that performs a find and replace and then edit the code afterwards.

Good luck!
Dan


 
DZiW (X)
DZiW (X)
Ukraine
English to Russian
+ ...
TOPIC STARTER
Finders Keepers May 30, 2015

Thank you for assistance, I did try to find/replace/select delimiters to no avail, yet I found out it's a semi-automated PDF conversion to DOC with all that infamous misformatting.

I agree that Find and select the target followed by direct formatting would be great, BUT the point is the empty lines somehow vary, e.g. double paragraph; paragraph + space + paragraph; paragraph + break + paragraph; paragraph + space + space + paragraph.

That's why I was unable to format it
... See more
Thank you for assistance, I did try to find/replace/select delimiters to no avail, yet I found out it's a semi-automated PDF conversion to DOC with all that infamous misformatting.

I agree that Find and select the target followed by direct formatting would be great, BUT the point is the empty lines somehow vary, e.g. double paragraph; paragraph + space + paragraph; paragraph + break + paragraph; paragraph + space + space + paragraph.

That's why I was unable to format it properly and thought it was something more complicated in a newer MS Word... till you gave me a hint)

Dan, Philip, I really appreciate it--especially at the gloomy face of formatting each paragraph manually.


Cheers.
Collapse


 
Tony M
Tony M
France
Local time: 10:16
Member
French to English
+ ...
SITE LOCALIZER
IF the document is formatted correctly in the first place... May 30, 2015

I could suggest another way, still using S&R

IF your blocks are separated correctly by soft line returns ^l and the paragraphs are separated by hard ones ^p, then you could simply do as the others have already suggested and replace double (or multiple) hard returns with a single one, and then include the white space in the 'Paragrpah' formatting as 'space before' or 'space after, according to which best suits your requirements; or of course, have a bit of each!

IF howev
... See more
I could suggest another way, still using S&R

IF your blocks are separated correctly by soft line returns ^l and the paragraphs are separated by hard ones ^p, then you could simply do as the others have already suggested and replace double (or multiple) hard returns with a single one, and then include the white space in the 'Paragrpah' formatting as 'space before' or 'space after, according to which best suits your requirements; or of course, have a bit of each!

IF however the document has not been formatted intelligently, i.e. the returns within the blocks are also hard ones, then you'll need to go about it a bit more long-windedly:

1) S & R for double (multiple) hard returns and replace them all with a unique character or character combination that never appears elsewhere in your document — e.g. § etc.

2) NOW replace all ^p with ^l

3) Replace all your [unique character]s with ^p, and you will have a correctly-formatted document.

4) Then all that remains to be done is to set the paragraph formatting to include your desired amount of whit space between the blocks.
Collapse


 
Dan Lucas
Dan Lucas  Identity Verified
United Kingdom
Local time: 09:16
Member (2014)
Japanese to English
Quite right May 30, 2015

Tony M wrote:
IF however the document has not been formatted intelligently, i.e. the returns within the blocks are also hard ones, then you'll need to go about it a bit more long-windedly:

I used to take the exact approach described above by Tony in the past. It works.

Dan


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

MS Word macro: empty lines font size






TM-Town
Manage your TMs and Terms ... and boost your translation business

Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.

More info »
Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »