PDA

View Full Version : Determine distance of footnote text from page margins



newbie101
05-21-2013, 05:52 AM
Hi Folks,

Recently I asked how to determine the distance of text from the page margins. The question was answered by macropod using this subroutine
Sub GetVerticalPosition()
Application.ScreenUpdating = False
Dim sTopMargin As Single, sBottomMargin As Single, sBottomLine As Single
Dim sPageHeight As Single, sPrintHeight As Single, sVertPos As Single
With Selection.Characters.First
sVertPos = .Information(wdVerticalPositionRelativeToTextBoundary) + _
.ParagraphFormat.SpaceBefore
With .PageSetup
sTopMargin = .TopMargin
sBottomMargin = .BottomMargin
sPageHeight = .PageHeight
End With
sPrintHeight = sPageHeight - sTopMargin - sBottomMargin
MsgBox "The top of the first selected character is " & sVertPos & _
" points below the top margin and " & sPrintHeight - sVertPos & _
" points above the bottom margin."
End With
Application.ScreenUpdating = True
End Sub


My question now is, is there a way to determine the same thing (distance of text from margins) for footnotes?

Thanks in advance.

Doug Robbins
05-26-2013, 12:49 AM
Assuming that it is actually the position of the Footnote Separator that you want, the following will give you the position of it in points from the top of the page of the first footnote separator in the document:

Dim astory As Range
With ActiveDocument
For Each astory In .StoryRanges
If astory.StoryType = wdFootnoteSeparatorStory Then
MsgBox astory.Information(wdVerticalPositionRelativeToPage)
End If
Next astory
End With

macropod
05-26-2013, 02:55 AM
Hi Doug,

Which could be reduced to:
MsgBox ActiveDocument.StoryRanges(wdFootnoteSeparatorStory).Information(wdVertical PositionRelativeToPage)

:beerchug:

newbie101
05-26-2013, 04:22 AM
It returns -1.

macropod
05-26-2013, 05:10 AM
Not when I use it ... both return the same value in a test A4 document (748.8) - Doug's twice.

newbie101
05-26-2013, 02:27 PM
Strange. In English documents it works but in Hebrew documents it returns -1. Any idea why?

macropod
05-26-2013, 02:28 PM
No.