Reading tabs stops

J

jb

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
 
H

Helmut Weber

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
 
J

jb

Helmut said:
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
 
H

Helmut Weber

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top