[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Macro required to copy all footnotes in a document.

Posted on 2007-10-01
4
Medium Priority
?
507 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:Astroman
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:geneus
ID: 19989997
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
0
 
LVL 1

Author Comment

by:Astroman
ID: 19990062
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
0
 
LVL 12

Accepted Solution

by:
geneus earned 2000 total points
ID: 19990282
The previous just saved the Text File.  This version save the Text file and adds it to the Clipboard:

Sub RefFootnotesClipboard()
    'Adds the Footnotes to a variable
    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
   
    'Creates a new blank document and pastes the result
    Documents.Add DocumentType:=wdNewBlankDocument
    Selection.HomeKey Unit:=wdStory
    Selection.InsertAfter varFNCollection
   
    'Copies the Result to the Clipboard
    Selection.WholeStory
    Selection.Copy
   
    'Saves the result as Accessible Text file
    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
   
    'Closes the document
    ActiveDocument.Close
   
    'Informs the user that the task is complete
    MsgBox "Done!"

End Sub

0
 
LVL 1

Author Comment

by:Astroman
ID: 19990735
Thanks very much -m does the trick, and importantly gives me a good starting point to extend it into my growing suite of macros!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question