Looping through styles and deleting blank lines

N

Nick Ward

Hi
I've had a good look through past posts and can't seem to find the answer
that will help me solve my problem.
I need to loop through about 5 lines of an address and collapse or delete
any blank lines that are present.

Dim para As Paragraph

For Each para In ActiveDocument.Paragraphs
If Len(para.Range.Text) <= 1 Then
para.Range.Delete
End If

Next

this as I have found deletes all blank lines in the doc but I only want to
delete the ones in the address section. I have assigned a style to each one
of the lines but can't figure out how to loop through each style and delete
where the paragraphs are blank

Any help would be much appreciated

rgds
 
J

Jezebel

Very simple. Instead of ActiveDocument.Paragraphs, you want only the range
containing the address. If you have that selected you could use: For each
para in Selection.Paragraphs

Or if you used a bookmark: For each para in AddressBookmark.Paragraphs

etc
 
N

Nick Ward

Thanks for that
Jezebel said:
Very simple. Instead of ActiveDocument.Paragraphs, you want only the range
containing the address. If you have that selected you could use: For each
para in Selection.Paragraphs

Or if you used a bookmark: For each para in AddressBookmark.Paragraphs

etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top