Aligning text

J

Jo Farnworth

Is there a way in Word (as there is in Wordperfect using
Flush commands)to align some words on a line with the
left margin and some words on the same line with the
right margin? In Wordperfect I could set up a document
with a title on the left side and the date aligned on the
right margin but cannot find a way in Word to do this.
 
G

Greg Maxey

Jo,

Here is a macro for doing this:

Sub FlushRight()

On Error GoTo ErrorHandling

Dim sngLeftMargin As Single 'left margin setting for current document
Dim sngRightMargin As Single 'right " " "
Dim sngPageWidth As Single 'page width " "
Dim sngWidthToRight As Single 'setting required for custom tab stop

'retrieve document's margin and page width settings
sngLeftMargin = CSng(ActiveDocument.PageSetup.LeftMargin)
sngRightMargin = CSng(ActiveDocument.PageSetup.RightMargin)
sngPageWidth = CSng(ActiveDocument.PageSetup.PageWidth)


sngWidthToRight = sngPageWidth - (sngLeftMargin + sngRightMargin)
Application.ScreenUpdating = False

With Selection
..Paragraphs.TabStops.Add _
Position:=sngWidthToRight, Alignment:=wdAlignTabRight,
Leader:=wdTabLeaderSpaces
..InsertAfter Text:=vbTab
..EndKey Unit:=wdLine

'ensure the next line has the default tab stop
If .Type = wdSelectionIP And _
..End = ActiveDocument.Content.End - 1 Then 'if no line below the current
Line
..TypeParagraph 'new line
Else 'move to the beginning of next line
..MoveDown _
Unit:=wdLine, _
Count:=1
End If

..ParagraphFormat.TabStops.ClearAll 'restore default tab stop
..MoveUp _
Unit:=wdLine, _
Count:=1 'move the insertion point...
..EndKey _
Unit:=wdLine '...to the right margin, ready for text
End With

Application.ScreenUpdating = True 'display on

ErrorHandling:
End Sub
 
D

Doug Robbins

Set the paragraph formatting to left aligned and set a right aligned tab on
the right margin and insert a tab space between the left and right parts of
the text.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

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