B
Boutang
For a W95-style help project, I'm trying to print an ordered list of document
footnotes. I've discovered what seems to be a bug in the Footnotes
collection.
Specifically, if you use For Each-Next with .Range.Footnotes, you get all
footnotes in the document instead of all footnotes in the range you've
specified.
Can anyone else confirm, or point out where my code is wrong?
Thanks.
Here's my code, commented where I think the bug is:
For Each ftnTopic In Documents(pstrDoc).Footnotes
If ftnTopic.Reference.Text = "#" Then 'It's a context ID
strTitle = ""
strBrowse = ""
'Get Topic Title and Browse Sequence
'I think this next line is buggy. For my document,
'.Range.Footnotes.Count=4, yet the For Each construct
'loops through every footnote in the document. This
'wrecks the values put into strTitle & strBrowse
For Each ftn In _
ftnTopic.Reference.Paragraphs(1).Range.Footnotes
If ftn.Reference.Text = "$" Then 'Topic Title
strTitle = ftn.Range.Text
End If
If ftn.Reference.Text = "+" Then 'Browse Sequence
strBrowse = ftn.Range.Text
End If
Next ftn
Documents(pstrDocNew).Range.InsertAfter """" _
& pstrDoc & """, """ & ftnTopic.Range.Text & """, """ _
& strTitle & """, """ & strBrowse & """" & vbCrLf
End If
Next ftnTopic
footnotes. I've discovered what seems to be a bug in the Footnotes
collection.
Specifically, if you use For Each-Next with .Range.Footnotes, you get all
footnotes in the document instead of all footnotes in the range you've
specified.
Can anyone else confirm, or point out where my code is wrong?
Thanks.
Here's my code, commented where I think the bug is:
For Each ftnTopic In Documents(pstrDoc).Footnotes
If ftnTopic.Reference.Text = "#" Then 'It's a context ID
strTitle = ""
strBrowse = ""
'Get Topic Title and Browse Sequence
'I think this next line is buggy. For my document,
'.Range.Footnotes.Count=4, yet the For Each construct
'loops through every footnote in the document. This
'wrecks the values put into strTitle & strBrowse
For Each ftn In _
ftnTopic.Reference.Paragraphs(1).Range.Footnotes
If ftn.Reference.Text = "$" Then 'Topic Title
strTitle = ftn.Range.Text
End If
If ftn.Reference.Text = "+" Then 'Browse Sequence
strBrowse = ftn.Range.Text
End If
Next ftn
Documents(pstrDocNew).Range.InsertAfter """" _
& pstrDoc & """, """ & ftnTopic.Range.Text & """, """ _
& strTitle & """, """ & strBrowse & """" & vbCrLf
End If
Next ftnTopic