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
Jezebel - 17 Oct 2005 05:49 GMT
Position:= (Activedocument.PageSetup.PageWidth -
Activedocument.PageSetup.RightMargin - Activedocument.PageSetup.LeftMargin)
>I wantt to write a macro to insert a right align tabstop just at the right
> margin of the the document.
[quoted text clipped - 9 lines]
>
> Thanks
ykchanaed - 17 Oct 2005 17:58 GMT
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.
> Position:= (Activedocument.PageSetup.PageWidth -
> Activedocument.PageSetup.RightMargin - Activedocument.PageSetup.LeftMargin)
[quoted text clipped - 12 lines]
> >
> > Thanks
Doug Robbins - 17 Oct 2005 18:19 GMT
Use
Dim pos As Double
With ActiveDocument.PageSetup
pos = .PageWidth - .LeftMargin - .RightMargin
End With
Selection.ParagraphFormat.TabStops.Add Position:=pos,
Alignment:=wdAlignTabRight

Signature
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
> Selection.ParagraphFormat.TabStops.Add
> Position:=ActiveDocument.PageSetup.rightmargin
[quoted text clipped - 23 lines]
>> >
>> > Thanks
ykchanaed - 21 Oct 2005 16:42 GMT
Hi,
thanks a lot.
I learn another way of writing macro.
> Use
>
[quoted text clipped - 32 lines]
> >> >
> >> > Thanks
ykchanaed - 17 Oct 2005 18:15 GMT
Oh I know what you mean !
it is :
page.width minus the 2 margin lenths
thanks!
> Position:= (Activedocument.PageSetup.PageWidth -
> Activedocument.PageSetup.RightMargin - Activedocument.PageSetup.LeftMargin)
[quoted text clipped - 12 lines]
> >
> > Thanks
Anne Troy - 17 Oct 2005 06:46 GMT
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
>I wantt to write a macro to insert a right align tabstop just at the right
> margin of the the document.
[quoted text clipped - 9 lines]
>
> Thanks
ykchanaed - 17 Oct 2005 19:41 GMT
Jezebel answered my question!
Thanks anyway!
> It would seem you need the "inches to points" thing. When I recorded
> creating a right-aligned tab, I get this:
[quoted text clipped - 20 lines]
> >
> > Thanks