Hi Julie,
Selection.ParagraphFormat.TabStops.Add _
Position:=InchesToPoints(rMar - CTab1), _
Alignment:=wdAlignTabLeft, _
Leader:=wdTabLeaderSpaces
The second line: was this supposed to be just CTab1, as in the following
(you use rMar to calculate a value for CTab1 a couple lines earlier)?
Selection.ParagraphFormat.TabStops.Add _
Position:=InchesToPoints(CTab1), _
Alignment:=wdAlignTabLeft, _
Leader:=wdTabLeaderSpaces
And in the next block of code, you specify the position of the right-aligned
tabstop as CurTab2, but you've only defined CTab2, is this correct?
HTH,
Dave
> Doh! I am losing it! That gives me the right margin, but something else is
> wrong in the code because it is not given me the tab position the length of
[quoted text clipped - 3 lines]
> >
> > rMar = ActiveDocument.PageSetup.RightMargin
singeredel - 28 Feb 2005 21:05 GMT
Hi Dave,
I had defined CTab1 = rMar - Len(sLen) - (6 / 72) previously. Was this
incorrect? You have it in the Add Tabstops section. Does this make a
difference? However, I get a run-time error 5149: The measurement must be
between -1584 pt and 1584 pt." I am wondering if it has to do with this
"Inches to Points" thing because I am already dealing with points, aren't I?
I couldn't find anything else that fit.
> Hi Julie,
>
[quoted text clipped - 24 lines]
> > >
> > > rMar = ActiveDocument.PageSetup.RightMargin
singeredel - 01 Mar 2005 01:55 GMT
Ignore the code in the last post and use the following:
Dim CTab As Variant
Dim CTab1 As Variant
Dim CTab2 As Variant
Dim sLen As Variant
Dim sLen1 As Variant
Dim sLen2 As Variant
Dim sLen3 As Variant
Dim sLen4 As Variant
sLen1 = Len(PatientName$)
sLen2 = Len(SSN$)
sLen3 = Len(AttentionLine$)
sLen4 = Len(DOE$)
If sLen1 >= sLen2 And sLen1 >= sLen3 And sLen1 >= sLen4 Then sLen =
sLen1
If sLen2 >= sLen1 And sLen2 >= sLen3 And sLen2 >= sLen4 Then sLen =
sLen2
If sLen3 >= sLen1 And sLen3 >= sLen2 And sLen3 >= sLen4 Then sLen =
sLen3
If sLen4 >= sLen1 And sLen4 >= sLen2 And sLen4 >= sLen3 Then sLen =
sLen4
rMar = ActiveDocument.PageSetup.RightMargin
CTab1 = Len(sLen + (6 / 72))
CTab2 = CTab1 - 0.15
Selection.ParagraphFormat.TabStops.Add _
Position:=InchesToPoints(rMar - CTab1), _
Alignment:=wdAlignTabLeft, _
Leader:=wdTabLeaderSpaces
Selection.ParagraphFormat.TabStops.Add _
Position:=InchestToPoints(CTab2), _
Alignment:=wdAlignTabRight, _
Leader:=wdTabLeaderSpaces
> Hi Julie,
>
[quoted text clipped - 24 lines]
> > >
> > > rMar = ActiveDocument.PageSetup.RightMargin
Dave Lett - 01 Mar 2005 13:07 GMT
So you have everything working then?
> Ignore the code in the last post and use the following:
>
[quoted text clipped - 63 lines]
> > > >
> > > > rMar = ActiveDocument.PageSetup.RightMargin
singeredel - 01 Mar 2005 16:09 GMT
No...I get the error that it is outside the measurement range.
> So you have everything working then?
>
[quoted text clipped - 72 lines]
> > > > >
> > > > > rMar = ActiveDocument.PageSetup.RightMargin
Dave Lett - 01 Mar 2005 17:12 GMT
Hi Julie,
Well, not knowing what you're values are puts me in a difficult position. At
the end of your routine (before "End Sub"), add the following and let's see
what we get:
MsgBox "CTab1:" & vbTab & CTab1 & vbCrLf & _
"CTab2:" & vbTab & CTab2 & vbCrLf & _
"rMar - CTab1:" & vbTab & rMar - CTab1
This way, we can see which values are outside the measurement range.
Dave
> No...I get the error that it is outside the measurement range.
>
[quoted text clipped - 74 lines]
> > > > > >
> > > > > > rMar = ActiveDocument.PageSetup.RightMargin
singeredel - 01 Mar 2005 19:04 GMT
Hi Dave,
Thanks for your help. The values displayed were:
CTab1 = 16
CTab2 = 15.85
rMar - CTab1 = 56
Obviously my logic is wrong. The right margin is set at 72 points (1") from
the right edge of the paper size of 8-1/2 x 11. It should probably be rMar +
CTab1. But the problem for me is how to convert this number to a tab location
based on points. Certainly CTab1 cannot be set at 70+16 or 86 points (86
points from the right margin maybe, but how do you write code to tell it
that?).
Thanks again!
Julie
Right now I am just using the following as strings to test:
PatientName$ = "Smith, Joe"
SSN$ = "555-55-5555"
AttentionLine$ = "John Doe"
DOE$ = "02/28/05"
> Hi Julie,
>
[quoted text clipped - 94 lines]
> > > > > > >
> > > > > > > rMar = ActiveDocument.PageSetup.RightMargin
Dave Lett - 01 Mar 2005 20:26 GMT
Hi Julie,
You have
rMar - CTab1 = 56
Both values are in points.
Then, the code has
Selection.ParagraphFormat.TabStops.Add _
Position:=InchesToPoints(rMar - CTab1), _
Alignment:=wdAlignTabLeft, _
Leader:=wdTabLeaderSpaces
See the problem? You're inflating something (rMar - CTab1), which is already
in points (i.e., 56 points), by treating it as if it were in Inches.
HTH,
Dave
> Hi Dave,
>
[quoted text clipped - 119 lines]
> > > > > > > >
> > > > > > > > rMar = ActiveDocument.PageSetup.RightMargin
singeredel - 01 Mar 2005 21:03 GMT
I did try taking the InchesToPoints out previously and still got an error,
but perhaps it was due to something else. I tried removing it again and now
the tabs are set from the left margin at .22" and .78". So I guess I need to
figure the distance from the left margin?? round and round and round I go! :D
> Hi Julie,
>
[quoted text clipped - 153 lines]
> > > > > > > > >
> > > > > > > > > rMar = ActiveDocument.PageSetup.RightMargin