Working with Footnotes

C

cfulmer

I'm writing a macro to do some word->HTML conversion. For part of this, I
need to be able to loop through the footnotes, grab the reference numbers and
insert them elsewhere in the text of the document. I need some help because
it just isn't working how I think it should.

I've tried two things:

(1) selecting the reference from the Footnote object and then
cutting-and-pasting into the body:

ActiveDocument.Footnotes(1).Reference.Select
Selection.Copy
.. . .
Selection.Paste

This creates another footnote. Not what I want.

(2) I've also tried just grabbing the text of the reference:

myRefNum$ = ActiveDocument.Footnotes(1).Reference.Text

But, for some reason, this gives me garbage (it comes out as a box).

Any ideas?

The other thing I should mention is that there are different styles of
footnotes in the documents and at least one numbering restart, so I can't
just go by the Footnote.Index.

Thx.
 
D

Dave Lett

Hi,

Can you use something like the following:

Dim lFtnt As Long
For lFtnt = ActiveDocument.Footnotes.Count To 1 Step -1
With ActiveDocument.Footnotes(lFtnt)
.Reference.InsertAfter "<fn" & lFtnt & ">" & .Range.Text & "<\fn>"
.Reference.Delete
End With
Next lFtnt

This, obviously, doesn't keep the different footnote numbering systems that
you mention.

HTH,
Dave
 
D

Dave Lett

Hi again,

You can, indeed, account for different numbering styles and restarts. The
following shows how you might branch for restarting (i.e., NumberingRule).
The comments would actually point to different routines:

With ActiveDocument.Footnotes
Select Case .NumberingRule
Case wdRestartContinuous
''' extract notes continuously
Case wdRestartSection
''' extract notes by section
Case wdRestartPage
''' extract notes by page
End Select
End With

So, in theory, you can account for the .NumberingRule and/or .NumberStyle.
You could concatenate the .NumberingRule and/or .NumberStyle and the index
number for that footnote. That is, since you'd know what .NumberingRule, you
can use the Index property because it the Xth footnote for that
page/section/document.

HTH,
Dave
 

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