tabstop at right margin

Y

ykchanaed

I wantt to write a macro to insert a right align tabstop just at the right
margin of the the document.
the .rightmargin in VBA only give the point from the right edge of the
document.
Hence,

Selection.ParagraphFormat.TabStops.Add Position:= .rightmargin,
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces

only add the tabstop at the, say, 90 points from the LEFT edge of the
document.

Thanks
 
J

Jezebel

Position:= (Activedocument.PageSetup.PageWidth -
Activedocument.PageSetup.RightMargin - Activedocument.PageSetup.LeftMargin)
 
A

Anne Troy

It would seem you need the "inches to points" thing. When I recorded
creating a right-aligned tab, I get this:
Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.5), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces

I'm sorry I don't know how to say "right margin", but you can specify the
location in inches.
************
Anne Troy
www.OfficeArticles.com
 
Y

ykchanaed

Selection.ParagraphFormat.TabStops.Add
Position:=ActiveDocument.PageSetup.rightmargin

when I tried the above, the tabstop was set at the point from the left margin,
that is, the same distance of the margin from the paper edge, but now it is
from the left margin.
 
D

Doug Robbins

Use

Dim pos As Double
With ActiveDocument.PageSetup
pos = .PageWidth - .LeftMargin - .RightMargin
End With
Selection.ParagraphFormat.TabStops.Add Position:=pos,
Alignment:=wdAlignTabRight


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
Y

ykchanaed

Jezebel answered my question!
Thanks anyway!

Anne Troy said:
It would seem you need the "inches to points" thing. When I recorded
creating a right-aligned tab, I get this:
Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.5), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces

I'm sorry I don't know how to say "right margin", but you can specify the
location in inches.
************
Anne Troy
www.OfficeArticles.com
 

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