PDA

View Full Version : VBA Macro to convert only certain footnotes to endnotes in Word?



CarlyO
04-01-2015, 07:14 PM
Hi, first post, hope I do this right.
I have a Word doc with lots of footnotes that are all custom marks, none automatically numbered. There are two types of custom mark: numerals and letters. So either 1, 2, 3 or a, b, c.
I want to convert ONLY the footnotes with letter marks, into endnotes.


I can convert all footnotes to endnotes with:


Sub ConvertFootnotesEndnotesTEST()
' Convert
ActiveDocument.Footnotes.Convert
With ActiveDocument.Range(Start:=ActiveDocument.Content.Start, End:= _
ActiveDocument.Content.End).FootnoteOptions
.Location = wdBottomOfPage
.NumberStyle = wdNoteNumberStyleLowercaseLetter
End With
' Renumbering
With ActiveDocument.Range(Start:=ActiveDocument.Content.Start, End:= _
ActiveDocument.Content.End).EndnoteOptions
.Location = wdEndOfDocument
.NumberingRule = wdRestartContinuous
.StartingNumber = 1
.NumberStyle = wdNoteNumberStyleLowercaseArabic
End With
End Sub



I thought stipulating the NumberStyle in the above would work; it doesn't. I'm not really a programmer, just a keen Word user.
I also tried "If Selection.Footnotes.NumberStyle = wdNoteNumberStyleLowercaseLetter Then Selection.Footnotes.Convert" but that doesn't work either.

I would be VERY grateful for some help with this! Thankyou.

gmayor
04-01-2015, 11:54 PM
Based on your description, the following should work



Sub ConvertLetterFootnotes()
Dim oFN As Footnote
For Each oFN In ActiveDocument.Footnotes
If Not IsNumeric(oFN.Reference) Then
oFN.Range.Footnotes.Convert
End If
Next oFN
lbl_Exit:
Exit Sub
End Sub

CarlyO
04-02-2015, 02:11 AM
Thankyou; that works for the majority of them. A couple of numbered ones are still showing up, which seems absurd given your parameters above, but I can manually tidy them up afterwards. Thanks!

gmayor
04-02-2015, 02:40 AM
Can you post a section of the document that has footnotes that are incorrectly converted by the macro?