![]() |
#1
|
|||
|
|||
![]()
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> HTML Code:
<sup>1</sup> 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 |
#2
|
||||
|
||||
![]()
See the 'UnLinkNotes' macro in: https://www.msofficeforums.com/word/...html#post35017. With the code there, all you need do is change the .InsertAfter & .InsertBefore strings, doing something similar to the references in the footnotes, too, if you wish.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
![]()
Cross-posted at: https://stackoverflow.com/questions/...cing-some-html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Swapping column and row formats. Letters to numbers etc. | AdamNT69 | Excel | 2 | 10-17-2016 08:44 AM |
![]() |
get4hari | Excel Programming | 8 | 09-26-2015 10:33 PM |
Search and replace/insert HTML code into Master File using tags | dave8555 | Excel | 2 | 02-23-2014 03:51 PM |
Strange HTML code inside an e-mail | Joostdegrote | Outlook | 0 | 09-13-2010 07:57 AM |
Can you actually write HTML and CSS in a word document and send it as an html page | jackaroo | Word | 0 | 07-12-2010 07:49 AM |