Hi Folks,
I'm looking for some help on reading Tab Stop information for every
style from a template (more than 100 styles many of which has more then
2 tabstops set).

Any help appreciated.

Cheers
J

RE: Reading tabs stops by HelmutWeber

HelmutWeber
Mon May 09 08:25:50 CDT 2005

Hi,

e.g.:

With ActiveDocument.Styles("Titel").ParagraphFormat
MsgBox .TabStops.Count
MsgBox .TabStops(1).Position
End With

Need help on looping, too?

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000



Re: Reading tabs stops by jb

jb
Tue May 10 05:31:02 CDT 2005

Helmut Weber wrote:
> Hi,
>
> e.g.:
>
> With ActiveDocument.Styles("Titel").ParagraphFormat
> MsgBox .TabStops.Count
> MsgBox .TabStops(1).Position
> End With
>
> Need help on looping, too?
>
> Greetings from Bavaria, Germany
> Helmut Weber, MVP
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
>
>
HI Helmut,

I'm able to read the info from the document and store in an .ini file,
but when I try to write the tabstops back it fails, usually setting the
first tab stop to 0cm but with the correct alignment and leader info.

Here's what I have so far...
Reading from document -

With sty.ParagraphFormat
ReSizeMultiDim i, "Tabs"
For y = 1 To .TabStops.Count
With .TabStops(y)
Test = .Position
If Len(Test) <> 0 Then
aStyArrParaTabPos(y, i) = Format(PointsToCentimeters(.Position), "0.00")
If Right(aStyArrParaTabPos(y, i), 2) = "00" Then
aStyArrParaTabPos(y, i) = Format(aStyArrParaTabPos(y, i), "0")
End If
aStyArrParaTabAlign(y, i) = .Alignment
aStyArrParaTabLeader(y, i) = .Leader
End If
End With
Next y

Writing back to document -

With mystyle.ParagraphFormat
ReSizeMultiDim i, "Tabs"
For y = 0 To lTabCount - 1
If mystyle.ParagraphFormat.TabStops.Count <= lTabCount Then
If Len(aStyArrParaTabPos(y, i)) <> 0 Then
mystyle.ParagraphFormat.TabStops.Add _
Position:=CentimetersToPoints(aStyArrParaTabPos(y, i)), _
Leader:=aStyArrParaTabLeader(y, i), _
Alignment:=aStyArrParaTabAlign(y, i)
If Right(aStyArrParaTabPos(y, i), 2) = "00" Then
aStyArrParaTabPos(y, i) = Format(aStyArrParaTabPos(y, i), "0")
End If
With .TabStops(y)
.Position = PointsToCentimeters(aStyArrParaTabPos(y, i))
.Alignment = aStyArrParaTabAlign(y, i)
.Leader = aStyArrParaTabLeader(y, i)
End With ' tabstops
End If
End If
Next y
End With 'mystyle



Cheers

J


Re: Reading tabs stops by Helmut

Helmut
Tue May 10 06:56:36 CDT 2005

Hi jb,

hm..., to tell the truth, I can only guess,
that mingling with data types and format may be the reason.
PointsoCentimeters excepts a single, and you pass a string,
triggering an implicit type conversion which behaves differently,
according to local settings.
Also, remove leader and alignment for testing purposes.
It makes the code very hard to read.
Furthermore,
> If Right(aStyArrParaTabPos(y, i), 2) = "00" Then
> aStyArrParaTabPos(y, i) = Format(aStyArrParaTabPos(y, i), "0")
> End If
appears twice in your code. At the second time,
it wouldn't do anything, as far as I see.

Certainly no solution, but might at least help debugging.
Maybe somebody else knows better, sorry.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org