Word Macro to Convert Non-Functional Endnotes/Footnotes

Robert M. Warren
Robert M. Warren Member Posts: 2,452 ✭✭✭
edited November 20 in English Forum

I have been using a down-and-dirty set of macros to convert "dead" endnotes and footnotes to "live" MS Word footnotes, which are functional in Logos when compiled as a Personal Book. I have attempted to dress it up a bit with an interface in order to share it. I might have missed it, but I don't believe anything similar has been posted.

This tool is Dropbox-linked here and I hope it is found useful by Forum friends. (*smile*)

A real programmer would most certainly be able to improve upon it, and is urged to do so and share it. Also, if anyone would like to include this in a larger set of tools, please do so.

The document contains the macro and the documentation, which should be read carefully and all cautions followed.

https://www.dropbox.com/s/gvhxteqylvrxnol/Footnote%20Converter%20V2.docm 

macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

Smile

Tagged:
«1

Comments

  • JohnB
    JohnB Member Posts: 1,085

    Great!!

    I had wondered about doing it myself but lacked the stamina to do something to cope with the various alternatives that one can find.

    Also it would have remained as a set of down-and-dirty macros with no interface.

    Thanks so much Robert.

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Updated Version.

    Good Afternoon:

    After using it for a few months, I have revised the converter so that font color and size can be unspecified.

    The Dropbox link is here:  https://www.dropbox.com/s/oosgb86xrjcfb0f/Footnote%20Converter%20V3.docm?dl=0 

    The earlier version linked above has been removed.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • George
    George Member Posts: 476 ✭✭

    Thank you, Robert!  Your generosity is much appreciated.

  • M G Smith
    M G Smith Member Posts: 49

    Robert, thank you for all your work with this.

    Now that I have found a workaround to some problems (see below) I am able to make footnotes "live" where before I could not have justified the time that would have been needed. That said, my initial attempts to use the earlier version, and this version of the macro put me off. So I hope my findings will encourage others to persevere and so gain the benefit I have from your work.

    I should say that my 'workflow' involves splitting the book file into different docx files for each chapter, so I ignore some of the earlier instructions in your file, however it is still necessary to check that footnotes are not split over more than one paragraph, for example.

    Problem and Workaround 1

    In the first file I had success with both the footnote numbers in the text, and at the beginning of the endnotes, were superscript. The fact that the macro was searching for the same thing in both locations proved important. I had previously left the default setting of 'delete' in the Old Footnotes section of the dialogue and this resulted in the macro falling over if it was unable to find any footnote number in the text (I have been unable to work out why some numbers give problems.) The workaround I stumbled on was simply to change the Old Footnotes section to 'keep'. Doing this allowed the macro to run successfully to completion, however, any footnote numbers missed in the text are now 'found' in the endnotes and for these missed numbers the footnote is created in the endnotes! Scrolling through the endnotes easily shows which, if any, numbers have been changed from plain numbers to footnote markers. It is no great work to note which numbers are affected and to manually create footnootes at the appropriate place. (I use a duplicate copy of the original docx file to aid in this process.) To give some idea of my findings, the stats for my heavily footnoted file were as follows: (number of footnotes, number of missed numbers) (90, 7); (71, 5); (123, 12); (194, 17); (101, 5); (98, 1); (79, 4); (4, 0). As a final step, the original endnote text is deleted manually.

    Problem and Workaround 2

    Encouraged by my success I moved on to another book where the footnote numbers in the text were superscript but not so in the endnotes. Here my initial results looked equally encouraging: the macro ran through to completion. However, checking quickly revealed that text had often been identified as footnote text in error. Indeed such was the confusion that resulted I consider it would be impossible to try to sort what resulted. The workaround in this case is to do a search and replace of the numbers marking each endnote and changing them to superscript. (I can detail the steps involved if it would be helpful). This may involve some work (and workaround 1 has then to be followed) but in contrast to the steps involved in manually creating footnotes I consider it to be well worthwhile.

    Thanks again for sharing this macro with us.

  • James Taylor
    James Taylor Member Posts: 1,408 ✭✭✭

    Anyone know if any macro's can work with Libreoffice, I don't have Word but I make a ton of PBs and I'm sure macros would save me so much time that it's probably worth me just splurging on Word/Office but either way, any thoughts? suggestions?

    Thanks, 

    james

    Logos 10  | Dell Inspiron 7373 | Windows 11 Pro 64, i7, 16GB, SSD | iPhone 13 Pro Max

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    MG: I am glad you found it useful.

    Like you, i have encountered some very stubborn documents with inconsistencies and/or difficult-to-determine font attributes. Sometimes I just acknowledge when I'm licked and I punt and live with the dead footnotes.

    The good part for me is I mainly convert Kindle books, which tend to be consistent. (But even then, there's some rascals.) I originally had ambitions to make better use of the PDFs at CCEL.org, which tend to have rich footnoting. But when I got Word 2013, most PDF footnote issues were solved, since it usually converts them live.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Anyone know if any macro's can work with Libreoffice, I don't have Word but I make a ton of PBs and I'm sure macros would save me so much time that it's probably worth me just splurging on Word/Office but either way, any thoughts?

    James:

    I'm not sure about programs other than MS Word. There are a few forum users who have a more varied knowledge about programming, etc., than I do. Perhaps one of them will chime in. I think most office suites run some kind of scripting or programming like Visual Basic, but I doubt they share the exact object model to run this particular set of macros.

    Something to consider: If your employer pays for one of a certain number of enterprise licences with MS, you might be eligible for their Home Use Program, whereby one pays a very low price ($10 US for me). and gets Office Professional. As long as you work for that employer and they continue in the license, it's perfectly legit. (It actually helps MS in the long run, developing knowledgeable and loyal users.)

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Virgil Buttram
    Virgil Buttram Member Posts: 358

    I may be missing something obvious...

    My endnotes are formatted as numbered lists. How to I configure the macro to identify them as followed by a period and a tab?

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    How to I configure the macro to identify them as followed by a period and a tab?

    Hi Virgil:

    Do this:  In the two "Characters following" boxes, enter "." then "^t" (no quotes). The ^t is Word's code for a tab character (which is non-displaying). To see non-displaying marks, click the button with the paragraph symbol ¶ on the Home tab.

    Codes I use frequently:

    Tab                             ^t
    Paragraph mark         ^13     (could use ^p, but only if not using wildcards)
    Non-breaking space    ^s      (this looks like a degree symbol when show ¶ is pressed)
    Manual line-break        ^l      (looks like the symbol on the Enter key on the keyboard when ¶ is pressed)

    Other codes can be seen by clicking Replace on the Home tab (at the right-end) and clicking the More>> button, then the Special button. You can probably find a long list of codes on the Web.

    Hope that helps.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Virgil Buttram
    Virgil Buttram Member Posts: 358

    Robert,

    I tried entering the '^t" and it didn't work. It appears that the macro does not read the numbering of a numbered list as the index number of the endnote. So far, I'm doing the conversion manually. Time consuming, but it works.

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Ah, yes, I understand now. I didn't realize it was a Word-controlled list; I just assume it was number-period-tab. The next time I revise the documentation, I'll add that the macro can only do things that Word's Find & Replace can do manually. I've tried it myself to no avail. Apparently Word stores these numbers somehow, but they're not visible for normal commands. They're probably some kind of Field, and since they're dynamic, they can't be manipulated like other elements.

    If anyone knows how to make Find & Replace recognize these kinds of numbers, let me know and I'll revise the macro.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    OK, Virgil:  I found a quickie way to convert (all of the) numbered-lists in a document:

    "...there is a quick way. Simply follow these steps:

    Open the document whose numbering you want to convert. (You may want to open a copy of the document so that you don't mess up the original document.)
    Press Alt+F11. Word displays the VBA Editor.
    Press Ctrl+G. This opens the Immediate window.
    Type the following in the Immediate window:
    ActiveDocument.Range.ListFormat.ConvertNumbersToText
    Press Enter."

    This came from this webpage:  http://wordribbon.tips.net/T010248_Converting_Automatic_Numbering_to_Manual_Numbering.html 

    You could also make that into a simple macro by entering this into a module in VBE:

    Sub ConvNumbList()

    ActiveDocument.Range.ListFormat.ConvertNumbersToText

    End Sub

    To view the VBE, you might have to expose the Developer tab, which MS hides by default, as part of their contest to out-nanny Apple. (File-->Options-->Customize the Ribbon-->check the Developer tab on the right side of the dialog.) Once you can see the Developer tab, you can also use the Macros button to execute the macro.

    Downside: this converts every numbered-list in the document. I experimented with changing "ActiveDocument" above to "Selection", but I was not able to select the numbers in the numbered-list.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Virgil Buttram
    Virgil Buttram Member Posts: 358

    I've already finished the document I was working on, but I will remember this trick for any future documents.

    Thanks!

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Thank you , too. This part of the thread might help someone down the road.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Virgil Buttram
    Virgil Buttram Member Posts: 358

    Thank you , too. This part of the thread might help someone down the road.

    Agreed!

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Good Afternoon:

    I upgraded to Word 2016 and the first time I tried this macro, I received a run-time error. During a search of some help forums, I stumbled upon a solution.

    Here is a Dropbox link to Version 4:   https://www.dropbox.com/s/l94rrxcjli1c4cm/Footnote%20Converter%20V4.docm?dl=0 

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Thanks, Robert! You've done a real service here; I have long wished that I could convert dead footnotes in DOCX files created from websites. It is a marvel to watch the macro insert the footnotes.

    The document on which I used the macro, Das jüdische Volk und seine heilige Schrift in der christlichen Bibel (http://www.vatican.va/roman_curia/congregations/cfaith/pcb_documents/rc_con_cfaith_doc_20020212_popolo-ebraico_ge.html), contains 355 footnotes. I changed the font size of the superscript in-text note markers to 11 and the "dead" notes to 11.5 to help the macro distinguish these correctly. For some reason the macro failed to insert five footnotes, so I ended up with 350, all of which were correctly identified. The new superscript markers were not font size 11, so it was easy to then search the document for the five size-11 unconverted note markers and manually insert live footnotes. I look forward to reading the document on my Kindle.

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Stijn Haelewyck
    Stijn Haelewyck Member Posts: 2

    Hi Robert,

    Your solution would be an absolute lifesaver!! Nice work.

    Could you relink the dropbox doc (or just copy paste the script)? You would save me and my colleagues days of work :)

    Thank you in advance!

    Stijn

  • DominicM
    DominicM Member Posts: 2,995 ✭✭✭

    Here is the relevant section from my macros - I borrowed it off the net and tweaked it a little, presumably Robert did similar, also made the wording a little clearer and defaulted it to [#] notes

    4477.pages.txt

    Never Deprive Anyone of Hope.. It Might Be ALL They Have

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Could you relink the dropbox doc (or just copy paste the script)?

    Yikes!  I must have fat-fingered the files into oblivion.

    Here's Version 4, in which I had to put a Word 2016 fix:  https://www.dropbox.com/s/heog8j4c7w7zwrg/Footnote%20Converter%20V4.docm?dl=0 

    Just in case it's needed, here's the older version that worked fine in Word 2013:  https://www.dropbox.com/s/vni9nx441v49xfp/Footnote%20Converter%20V3.docm?dl=0 

    Follow the instructions and caveats and remember:  sometimes you just have to drop back five yards and punt.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Stijn Haelewyck
    Stijn Haelewyck Member Posts: 2

    I cannot thank you both enough! Works like a charm. Seriously considering to name my first-born after you guys.

    Cheers!

  • DominicM
    DominicM Member Posts: 2,995 ✭✭✭

    If they might be of interest please feel to post in this files forum, as long as they are out of copyright

    Never Deprive Anyone of Hope.. It Might Be ALL They Have

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Seriously considering to name my first-born after you guys.

    If a girl, she'll thank you later for Dominique and not Roberta [:D]

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Fr Devin Roza
    Fr Devin Roza Member, MVP Posts: 2,409

    Here's Version 4, in which I had to put a Word 2016 fix:  https://www.dropbox.com/s/heog8j4c7w7zwrg/Footnote%20Converter%20V4.docm?dl=0 

    Thanks so much again for this macro. It's a real life-saver! 

    I recently upgraded to Word 2016, and was having trouble making the macro work (getting the 4605 error, even with v4). I ended up putting 3 consecutive DoEvents instead of just 1 and now it is working like a charm. Could be that faster computers need more than one DoEvents to allow Word time to catch up with the macro? Not sure, anyway thanks again for a great macro.

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Could be that faster computers need more than one DoEvents to allow Word time to catch up with the macro?

    Aha! Reminds me that not only had I gone from Word 2013 to 2016, at the same time I had moved to a faster computer. Causality vs. Covariation continues to vex.

    Happy it's helpful.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Daniel Wurzberg
    Daniel Wurzberg Member Posts: 146

    Just wondering if any of you did any update to this amazing tools. 

    I can't get them to work for a very strange reason...my footnote ID numbers in the text look like subscripts, but they are not...just plain "Normal" text...even if I try and clear the style they stay the same.....anyways...just wondering if you did any update on this macro since 2017, tnx

  • Robert M. Warren
    Robert M. Warren Member Posts: 2,452 ✭✭✭

    Hi Daniel:

    No updates since then.

    Try using another differentiating attribute, like font size or color. I occasionally have footnote markers that I just can't figure out.

    macOS (Logos Pro - Beta) | Android 13 (Logos Stable)

    Smile

  • Thiago Samico
    Thiago Samico Member Posts: 59

    Robert, first of all, thank you so much!!!

    I'm coming from another thread where you suggested me to keep in track with this one!

    After some attempts I was able to make it work on my 1805 notes (!) document. 

    However, when the macro found note 1028 it showed me an error(5101). No problem! 

    But now, how can I restart the process from note 1028. The previous ones are perfect. 

    I tried a simple restart but the macro restarted the counting, so note 1029 became footnote 1!!!

    How to retake from note 1029 making sure the next footnote will be 1029 and som on?

    Again, thank you so much!