I have never worked with macros before so don't really understand the coding. I'm trying to get a macro that takes footnotes and converts them to regular text that can then easily be copied and pasted into our website editor. I have found some create macros out there that do almost all of this, but the superscript numbers have a weird span on them instead of the correct <sup> code. I'm struggling to find something that corrects that.
So currently when you look at the HTML Word is generating you get:
HTML Code:
<span class=MsoEndnoteReference>1</span>
You should just get:
Here is the macro I have thus far with bits I've found online. It first converts footnotes to endnotes and changes it to use numbers instead of Roman numerals. Then it changes them all to regular text. Lastly it removes bookmark links. The only piece of the puzzle I'm missing is making those spans superscripts.
Code:
Sub CleanNotes()
ActiveDocument.Footnotes.Convert
With ActiveDocument.Range(Start:=ActiveDocument.Content.Start, End:= _
ActiveDocument.Content.End).EndnoteOptions
.Location = wdEndOfDocument
.NumberingRule = wdRestartContinuous
.StartingNumber = 1
.NumberStyle = wdNoteNumberStyleArabic
End With
Application.ScreenUpdating = False
Dim nRng As Range, eNote As Endnote, nRef As String
With ActiveDocument
For Each eNote In .Endnotes
With eNote
With .Reference.Characters.First
.Collapse wdCollapseStart
.InsertCrossReference wdRefTypeEndnote, wdEndnoteNumberFormatted, eNote.Index
nRef = .Characters.First.Fields(1).Result
.Characters.First.Fields(1).Unlink
End With
.Range.Cut
End With
If .Range.EndnoteOptions.Location = wdEndOfSection Then
Set nRng = eNote.Range.Sections.First.Range
Else
Set nRng = .Range
End If
With nRng
.Collapse wdCollapseEnd
.End = .End - 1
If .Characters.Last <> Chr(12) Then .InsertAfter vbCr
.InsertAfter nRef & " "
With .Paragraphs.Last.Range
.Style = "Endnote Text"
.Words.First.Style = "Endnote Reference"
End With
.Collapse wdCollapseEnd
.Paste
If .Characters.Last = Chr(12) Then .InsertAfter vbCr
End With
Next
For Each eNote In .Endnotes
eNote.Delete
Next
End With
Set nRng = Nothing
Application.ScreenUpdating = True
Dim bkm As Bookmark
For Each bkm In ActiveDocument.Bookmarks
bkm.Delete
Next bkm
End Sub
Thank you!