Re: Any helper re setting tab stops (thank you!)
From: singeredel (singeredel_at_discussions.microsoft.com)
Date: 03/01/05
- Next message: Howard Kaikow: "Re: Execute Method of Find Object"
- Previous message: Jonathan West: "Re: template maximum size"
- In reply to: Helmut Weber: "Re: Any helper re setting tab stops (thank you!)"
- Next in thread: Helmut Weber: "Re: Any helper re setting tab stops (thank you!)"
- Reply: Helmut Weber: "Re: Any helper re setting tab stops (thank you!)"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 1 Mar 2005 13:37:01 -0800
Thank you so much. Your test was successful using your string sTm; however,
when I applied your code using my variables, for some reason it sets the tab
at 6.31", which does not accommodate the length of the variable with a margin
of 6.5". I am sorry to try your patience. Perhaps you would be kind enough to
look at my latest version and see if you spot something I am doing wrong. My
additions are indented. I never though this would be that difficult! :O
PatientName$ = "Smith, Joe"
SSN$ = "555-55-5555"
AttentionLine$ = "John Doe"
DOE$ = "02/28/05"
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
Dim sLen As Single
Dim sLen1 As Single
Dim sLen2 As Single
Dim sLen3 As Single
Dim sLen4 As Single
sLen1 = Len(PatientName$)
sLen2 = Len(SSN$)
sLen3 = Len(AttentionLine$)
sLen4 = Len(DOE$)
If sLen1 >= sLen2 And sLen1 >= sLen3 And sLen1 >= sLen4 Then sTm =
sLen1
If sLen2 >= sLen1 And sLen2 >= sLen3 And sLen2 >= sLen4 Then sTm =
sLen2
If sLen3 >= sLen1 And sLen3 >= sLen2 And sLen3 >= sLen4 Then sTm =
sLen3
If sLen4 >= sLen1 And sLen4 >= sLen2 And sLen4 >= sLen3 Then sTm =
sLen4
With ActiveDocument.PageSetup
sLM = .LeftMargin
sRM = .RightMargin ' 72
sPW = .PageWidth ' 612
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
Julie
"Helmut Weber" wrote:
> 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/
>
>
>
>
>
>
>
- Next message: Howard Kaikow: "Re: Execute Method of Find Object"
- Previous message: Jonathan West: "Re: template maximum size"
- In reply to: Helmut Weber: "Re: Any helper re setting tab stops (thank you!)"
- Next in thread: Helmut Weber: "Re: Any helper re setting tab stops (thank you!)"
- Reply: Helmut Weber: "Re: Any helper re setting tab stops (thank you!)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|