Link to home
Create AccountLog in
Avatar of Astroman
Astroman

asked on

Macro required to copy all footnotes in a document.

Can someone give me a macro to copy all the footnotes in the document to the clipboard as a numbered list?

I use the footnotes for managing open questions, and I could do with being able to just click a button to copy them all so I can stick them in a text file (if you can make the macro write to a new text file instead, even better!) I guess it could be useful to extract the document name and page number of each footnote too, but not essential...

It must work on Word 2002.

Ta,

Leon
Avatar of geneus
geneus
Flag of United States of America image

Here you go!

Sub RefFootnotes()

    For a = 1 To ActiveDocument.Footnotes.Count

        varFNIndex = ActiveDocument.Footnotes(a).Index
        varFNText = ActiveDocument.Footnotes(a).Range.Text
        varFNRef = varFNIndex & ". " & varFNText & Chr(10)
        varFNCollection = varFNCollection + varFNRef

    Next a

    Documents.Add DocumentType:=wdNewBlankDocument
    Selection.HomeKey Unit:=wdStory
    Selection.InsertAfter varFNCollection
   
    ChangeFileOpenDirectory "C:\Temp\"
   
    ActiveDocument.SaveAs FileName:="C:\Temp\Footnotes.txt", FileFormat:=wdFormatText, _
         LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False, Encoding:=1252, InsertLineBreaks:=False, AllowSubstitutions:=False _
        , LineEnding:=wdCRLF
    ActiveDocument.Close

    MsgBox "Done!"



End Sub
Avatar of Astroman
Astroman

ASKER

Does that also stick the list in the clipboard?

I will give it a try later (off to a meeting now). Looks good to me though  :-)

Leon
ASKER CERTIFIED SOLUTION
Avatar of geneus
geneus
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanks very much -m does the trick, and importantly gives me a good starting point to extend it into my growing suite of macros!