Retrieving tab stop information from built-in footnote style

A

andreas

Dear Experts:
I wonder whether it is possible to retrieve all the tabstop stops that
have been set (Tabstop Position and Alignment) for the built-in
footnote style and display the result in a Msgbox such as...
Examples:
No tabs set for the bulit-in footnote style or...
1 left aligned tab stop, position 3.5 cm and
1 right aligned tab stop, position 4.2 cm

Help is much appreciated. Thank you very much in advance. Regards,
Andreas
 
P

Pesach Shelnitz

Hi Andreas,

Try this. Note that the positions are in points.

Sub ListFootnoteStyleTabStops()

Dim tbStop As TabStop
Dim tabstopList As String
Dim align As String

With ActiveDocument.Styles(wdStyleFootnoteText).ParagraphFormat
If .TabStops.Count >= 1 Then
tabstopList = "Position" & vbTab & "Alignment" & vbCrLf
Else
tabstoList = "No tab stops are configured."
End If
For Each tbStop In .TabStops
Select Case tbStop.Alignment
Case Is = wdAlignTabLeft
align = "Left"
Case Is = wdAlignTabCenter
align = "Center"
Case Is = wdAlignTabRight
align = "Right"
Case Is = wdAlignTabDecimal
align = "Decimal"
Case Is = wdAlignTabBar
align = "Tab Bar"
Case Is = wdAlignTabList
align = "Tab List"
Case Else
End Select
tabstopList = tabstopList & tbStop.Position & " pt" _
& vbTab & align & vbCrLf
Next
End With
MsgBox tabstopList
End Sub
 
J

Jean-Guy Marcil

Pesach Shelnitz was telling us:
Pesach Shelnitz nous racontait que :
Hi Andreas,

Try this. Note that the positions are in points.

Sub ListFootnoteStyleTabStops()

Dim tbStop As TabStop
Dim tabstopList As String
Dim align As String

With ActiveDocument.Styles(wdStyleFootnoteText).ParagraphFormat
If .TabStops.Count >= 1 Then
tabstopList = "Position" & vbTab & "Alignment" & vbCrLf
Else
tabstoList = "No tab stops are configured."
End If
For Each tbStop In .TabStops
Select Case tbStop.Alignment
Case Is = wdAlignTabLeft
align = "Left"
Case Is = wdAlignTabCenter
align = "Center"
Case Is = wdAlignTabRight
align = "Right"
Case Is = wdAlignTabDecimal
align = "Decimal"
Case Is = wdAlignTabBar
align = "Tab Bar"
Case Is = wdAlignTabList
align = "Tab List"
Case Else
End Select
tabstopList = tabstopList & tbStop.Position & " pt" _
& vbTab & align & vbCrLf
Next
End With
MsgBox tabstopList
End Sub

To get inches, use this line instead:

tabstopList = tabstopList & Format(PointsToInches(tbStop.Position),
"#,##0.00") & " in" _
& vbTab & align & vbCrLf

By the way, there is a typo in the line:
tabstoList = "No tab stops are configured."

"tabstoList" should be "tabstopList"
 
P

Pesach Shelnitz

Hi,

Thank you Jean-Guy for noticing the typo in my macro and for showing me how
to convert points to inches. Since Andreas originally referred to
centimeters, I modified your suggestion a bit and fixed the macro to display
the results in centimeters. Here is my revised version.

Sub ListFootnoteStyleTabStops()

Dim tbStop As TabStop
Dim tabstopList As String
Dim align As String

With ActiveDocument.Styles(wdStyleFootnoteText).ParagraphFormat
If .TabStops.Count >= 1 Then
tabstopList = "Position" & vbTab & "Alignment" & vbCrLf
Else
tabstopList = "No tab stops are configured."
End If
For Each tbStop In .TabStops
Select Case tbStop.Alignment
Case Is = wdAlignTabLeft
align = "Left"
Case Is = wdAlignTabCenter
align = "Center"
Case Is = wdAlignTabRight
align = "Right"
Case Is = wdAlignTabDecimal
align = "Decimal"
Case Is = wdAlignTabBar
align = "Tab Bar"
Case Is = wdAlignTabList
align = "Tab List"
Case Else
End Select
tabstopList = tabstopList & _
Format(PointsToCentimeters(tbStop.Position), "##0.00") _
& " cm" & vbTab & align & vbCrLf
Next
End With
MsgBox tabstopList
End Sub
 
A

andreas

Hi,

Thank you Jean-Guy for noticing the typo in my macro and for showing me how
to convert points to inches. Since Andreas originally referred to
centimeters, I modified your suggestion a bit and fixed the macro to display
the results in centimeters. Here is my revised version.

Sub ListFootnoteStyleTabStops()

    Dim tbStop As TabStop
    Dim tabstopList As String
    Dim align As String

    With ActiveDocument.Styles(wdStyleFootnoteText).ParagraphFormat
        If .TabStops.Count >= 1 Then
            tabstopList = "Position" & vbTab & "Alignment" & vbCrLf
        Else
            tabstopList = "No tab stops are configured."
        End If
        For Each tbStop In .TabStops
            Select Case tbStop.Alignment
                Case Is = wdAlignTabLeft
                    align = "Left"
                Case Is = wdAlignTabCenter
                    align = "Center"
                Case Is = wdAlignTabRight
                    align = "Right"
                Case Is = wdAlignTabDecimal
                    align = "Decimal"
                Case Is = wdAlignTabBar
                    align = "Tab Bar"
                Case Is = wdAlignTabList
                    align = "Tab List"
                Case Else
            End Select
            tabstopList = tabstopList & _
                Format(PointsToCentimeters(tbStop.Position), "##0.00") _
                & " cm" & vbTab & align & vbCrLf
        Next
    End With
    MsgBox tabstopList
End Sub

--
Hope this helps,
Pesach Shelnitz









- Show quoted text -

Hey Pesach,

what a terrfic help! It works as desired. Thank you very much.
Regards, Andreas
 
A

andreas

Pesach Shelnitz was telling us:
Pesach Shelnitz nous racontait que :










To get inches, use this line instead:

tabstopList = tabstopList & Format(PointsToInches(tbStop.Position),
"#,##0.00") & " in" _
    & vbTab & align & vbCrLf

By the way, there is a typo in the line:
    tabstoList = "No tab stops are configured."

"tabstoList" should be "tabstopList"

--
______________________________
Jean-Guy Marcil
Montreal, Canada- Hide quoted text -

- Show quoted text -


Dear Jean,

thank you very much in aiding in the creation of this macro. It works
just fine. Terrific Help! Thank you again, Regards, Andreas
 
J

Jean-Guy Marcil

andreas was telling us:
andreas nous racontait que :
Dear Jean,

thank you very much in aiding in the creation of this macro. It works
just fine. Terrific Help! Thank you again, Regards, Andreas

You're welcome!
 

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