Can I convert footnote numbers to text

I

ingrid

I'm working with a document where the author has used the automated endnote
facility in Word. Since this is about to be translated into Quark for
typesetting, I need the endnote marks and the numbers with the endnotes to be
real numbers, not endnote marks -- Quark will not read them as numbers.
I was sure I did the conversion using ActiveDocument.ConvertNumbersToText in
Visual Basic once before, but I can't seem to make it work. Help! There are
20 chapters with about 40 endnotes each.
 
S

Stefan Blom

ActiveDocument.ConvertNumbersToText only works with paragraph numbering (and
LISTNUM fields). For endnotes, you can use the following macro created by
MVP Doug Robbins:

Sub ConvertEndNotesToText()
'Created by Doug Robbins

Dim aendnote As Endnote


For Each aendnote In ActiveDocument.Endnotes


ActiveDocument.Range.InsertAfter _
vbCr & aendnote.Index & vbTab & aendnote.Range


aendnote.Reference.InsertBefore "a" & aendnote.Index & "a"


Next aendnote


For Each aendnote In ActiveDocument.Endnotes


aendnote.Reference.Delete


Next aendnote


Selection.Find.ClearFormatting


Selection.Find.Replacement.ClearFormatting


With Selection.Find.Replacement.Font


.Superscript = True


End With


With Selection.Find


.Text = "(a)([0-9]{1,})(a)"


.Replacement.Text = "\2"


.Forward = True


.Wrap = wdFindContinue


.Format = True


.MatchWildcards = True


End With


Selection.Find.Execute Replace:=wdReplaceAll

End Sub

If you need assistance, see http://www.gmayor.com/installing_macro.htm.
 
Joined
Mar 16, 2014
Messages
3
Reaction score
0
It is rather strange to add a comment on the 4 years old thread.
But I found a couple of mistakes in the above Macro.
It will not run as is.
Here is the fixed version I made:
---------------------------------------------
Sub ConvertEndNotesToText()
'Created by Doug Robbins

Dim aendnote As Endnote


For Each aendnote In ActiveDocument.Endnotes


ActiveDocument.Range.InsertAfter _
vbCr & aendnote.Index & vbTab & aendnote.Range


aendnote.Reference.InsertBefore "" & aendnote.Index & ""


Next aendnote


For Each aendnote In ActiveDocument.Endnotes


aendnote.Reference.Delete


Next aendnote


Selection.Find.ClearFormatting


Selection.Find.Replacement.ClearFormatting


With Selection.Find.Replacement.Font


.Superscript = True


End With


With Selection.Find


.Text = "([0-9]{1,})"


.Replacement.Text = "\2"


.Forward = True


.Wrap = wdFindContinue


.Format = True


.MatchWildcards = False


End With


Selection.Find.Execute Replace:=wdReplaceAll

End Sub
--------------------------------------
I am nevertheless very grateful to the person who wrote the original Macro.:bow:
It helped me to convert over 100 footnotes to text format without manually retyping them.
I decided to post the fixed version for someone facing the same problem.
 
Joined
Oct 14, 2016
Messages
1
Reaction score
0
And 2-1/2 years later still, here's my "corrected" version, which works with endnote marks that aren't superscript and uses a cleaner wildcard search.
Code:
Sub endnotenum2fixed()
'Created by Doug Robbins
Dim aendnote As Endnote
For Each aendnote In ActiveDocument.Endnotes
    ActiveDocument.Range.InsertAfter _
    vbCr & aendnote.Index & vbTab & aendnote.Range
    aendnote.Reference.InsertBefore "a" & aendnote.Index & "a"
Next aendnote
For Each aendnote In ActiveDocument.Endnotes
    aendnote.Reference.Delete
Next aendnote
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
    .Text = "a([0-9]{1,2})a"
    .Replacement.Text = "\1"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
Joined
Sep 2, 2017
Messages
1
Reaction score
0
Thank you so much for this macro.
The thing is that all the formatting of the endnotes are changed to normal text.
Is there a way to keep the formatting of everything excluding the endnote reference?
 

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