Solved

Need MS Word Macro to replace footnotes and endnotes

Posted on 2011-09-20
2
656 Views
Last Modified: 2012-06-27
So there is an application that we load documents into that just cannot handle footnotes and endnotes in a MSWord document. So I need to code something that takes each footnote and endnote in a document and replaces it. I need the code to copy the footnote and/or endnote text and then paste the text where the footnote or endnote mark is, then delete the footnote or endnote. So the end goal is the footnote and endnote text ends up where the mark was and there is not longer footnotes and endnotes in the document.

I've attached a before and after document of basically what I want to occur in the document. I added the text "Footnote: " and "Endnote:" and put the replacement in parenthesis because although I think it would give an idea to the user exactly why its not nicely formatted and just kinda jammed into the middle of the document. But if thats more work and its just easier to dump the note in place of the mark then I'm fine with that.
Before.doc
After.doc
0
Comment
Question by:KGNickl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 500 total points
ID: 36567230
Here is a macro that does what you ask:

Public Sub ReplNotes()

    Dim d As Word.Document
    Dim f As Footnote
    Dim e As Endnote
    Dim i As Long
    Dim strText As String
    Dim rngRef As Word.Range
    
    Set d = ThisDocument
    
    For i = d.Footnotes.Count To 1 Step -1
        Set f = d.Footnotes(i)
        strText = f.Range.Text
        
        Set rngRef = f.Reference
        
        rngRef.Delete
        rngRef.InsertAfter " (Footnote: " & strText & ") "
        
    Next i

    For i = d.Endnotes.Count To 1 Step -1
        Set e = d.Endnotes(i)
        strText = e.Range.Text
        
        Set rngRef = e.Reference
        
        rngRef.Delete
        rngRef.InsertAfter " (Endnote: " & strText & ") "
        
    Next i

End Sub

Open in new window


Just locate and run the macro ReplNotes - I attach your Before file with macro added Before.doc
0
 
LVL 5

Author Closing Comment

by:KGNickl
ID: 36567525
I haven't tried it, but will assume it works. I actually finished the perl code for the same between posting this question and seeings your questions. After digging in the word API for a few minutes I realized it was actually pretty easy to do.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

707 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