Reading info from styles

J

jb

Hi Folks,

I'm trying to find a quick and dirty way of reading the Tab information
(Alignment & leader), Bullet information (whether bulleted, Numbered or
Outline Numbered and all the customizations) and Border settings from a
style.

Any pointers, Especially on the Tab and Numbering, would be grately
appreciated.

Thanks

J
 
C

Chuck

Not sure this is quick or dirty really, because from what I understand you've
got to pull the settings out individually. Still you loop through tabs for
their settings and pull other information out thusly (this isn't exhaustive,
it gives you an idea of what needs to be done). Unfortunately, the values
returned are index values, not descriptive strings, so you'll have to figure
out what index means what yourself, unless someone else has a better idea:

Dim strStyle As String
Dim i As Long
Dim strAlignment As String
Dim strLeader As String
Dim strBorderLeft As String

strStyle = Selection.Style

With ActiveDocument.Styles(strStyle).ParagraphFormat

'Tab settings
For i = 1 To .TabStops.Count
With .TabStops(i)
MsgBox "Tab at position " & PointsToInches(.Position) & _
" alignment is " & .Alignment & _
" and leader is " & .Leader
End With
Next i

'Border settings
strBorderLeft = .Borders(wdBorderLeft).LineStyle
MsgBox "Left border is " & strBorderLeft

'etc you get the idea

End With
 
J

jb

Chuck said:
Not sure this is quick or dirty really, because from what I understand you've
got to pull the settings out individually. Still you loop through tabs for
their settings and pull other information out thusly (this isn't exhaustive,
it gives you an idea of what needs to be done). Unfortunately, the values
returned are index values, not descriptive strings, so you'll have to figure
out what index means what yourself, unless someone else has a better idea:

Dim strStyle As String
Dim i As Long
Dim strAlignment As String
Dim strLeader As String
Dim strBorderLeft As String

strStyle = Selection.Style

With ActiveDocument.Styles(strStyle).ParagraphFormat

'Tab settings
For i = 1 To .TabStops.Count
With .TabStops(i)
MsgBox "Tab at position " & PointsToInches(.Position) & _
" alignment is " & .Alignment & _
" and leader is " & .Leader
End With
Next i

'Border settings
strBorderLeft = .Borders(wdBorderLeft).LineStyle
MsgBox "Left border is " & strBorderLeft

'etc you get the idea

End With



:
Thanks Chuck, Worked well for me.

Cheers
J
 

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