how to align text in paragraph form?

H

hsg

I have inserted large wordpad file into word document. While inserting, the
nice looking justified paragraph becomes unruly, and lines appear broken.

How can we create a macro that will start from top and shall repeat the
following functions:

1. go to end of line, delete extra spaces in between lines, and repeat
same if still
there is space left in the line
2. go to next line, repeat same process until end of paragraph is reached.
3. continue till end of document, or till a specified point and make the
entire text,
so far adjusted, as justified.

thanks in advance
 
J

Jean-Guy Marcil

hsg was telling us:
hsg nous racontait que :
I have inserted large wordpad file into word document. While
inserting, the nice looking justified paragraph becomes unruly, and
lines appear broken.

How can we create a macro that will start from top and shall repeat
the following functions:

1. go to end of line, delete extra spaces in between lines, and
repeat same if still
there is space left in the line
2. go to next line, repeat same process until end of paragraph is
reached.
3. continue till end of document, or till a specified point and make
the entire text,
so far adjusted, as justified.

Try this:

'_______________________________________
Dim DocRange As Range

Set DocRange = ActiveDocument.Range

With DocRange.Find
.Forward = True
.ClearFormatting
.Wrap = wdFindContinue
Do
.Execute FindText:=" ", Wrap:=wdFindContinue, _
ReplaceWith:=" ", Replace:=wdReplaceAll
Loop While .Found = True
End With

DocRange.ParagraphFormat.Alignment = wdAlignParagraphJustify
'_______________________________________

Use
Set DocRange = 'Some Range
to target specific parts of a document.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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