PDA

View Full Version : footnote numbers



marcelma
12-03-2011, 11:13 AM
Hello,

is there any possibility in VBA to find out which footnote number belongs to the footnote in which the insertion point is located?

thanks in advance,
Marcel

macropod
12-04-2011, 08:14 PM
Hi Marcel,

Try something like:
Sub Test()
Dim oNt As Footnote
If Selection.StoryType = wdFootnotesStory Then
For Each oNt In ActiveDocument.Footnotes
If oNt.Range.Start <= Selection.Start Then
If oNt.Range.End >= Selection.End Then
MsgBox oNt.Index
Exit For
End If
End If
Next
End If
End Sub

gmaxey
12-04-2011, 08:22 PM
Paul,

Wouldn't this work as well:

Dim oNt As Footnote
If Selection.StoryType = wdFootnotesStory Then
Set oNt = Selection.Footnotes(1)
MsgBox oNt.Index
End If

macropod
12-04-2011, 08:34 PM
Paul,

Wouldn't this work as well:

Dim oNt As Footnote
If Selection.StoryType = wdFootnotesStory Then
Set oNt = Selection.Footnotes(1)
MsgBox oNt.Index
End If
No, Greg, it wouldn't! ... It'd work better (more efficient).

Better still:
If Selection.StoryType = wdFootnotesStory Then MsgBox (Selection.Footnotes(1).Index)

gmaxey
12-05-2011, 05:34 AM
Paul,

But this is shorter:
If Selection.StoryType = 2 Then MsgBox (Selection.Footnotes(1).Index)

;-)