Hi Julie,
When I ran your code, I got 7.13 to 7.19, but I don't know what this means.
7.13 to 7.19 would be the width of a character in points,
according to the measuring method applied,
which seems to be constantly 6, by the way,
for courier new 10 point size with zoom factor 200 percent.
I do not understand this "approximate factor."
If you get different values for the width of a character,
you have to decide, whether you want to use the minimum width,
maximum width or the average or just add or deduct some constant
value from the possibly varying width of the complete string.
You might also call it a "corrective".
What was missing in my calculation was the left margin. :-(
So we got this, not regarding gutter width, which I left out:
Sub CalcTabPositionCell()
Dim sTm As String ' temporary string
Dim sRM As Single ' right margin
Dim sLM As Single ' left margin
Dim sPW As Single ' page width
Dim sPs As Single ' position of tabstop
With ActiveDocument.PageSetup
sLM = .LeftMargin
sRM = .RightMargin ' 70
sPW = .PageWidth ' 595
End With
sPs = sPW - (sLM + sRM)
sTm = "To be or not to be"
' deduce from tab position on left margin
' the approximately lenght of the string
sPs = sPs - (Len(sTm)) * 6 - 2 ' corrective 2
Selection.Paragraphs(1).TabStops.Add _
Position:=sPs, _
Alignment:=wdAlignTabLeft
End Sub
which puts a tabstop left from the right margin,
just left enough to hold "To be or not to be".
Given that a character is 6 points wide plus 2 points
to correct fractions or inconsistencies in the calculation.
Tested with zoom 200 percent
on 21 cm wide paper (DIN A4),
left margin = 2.5 cm
right margin = 2.5 cm
no gutter
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/