I maintain a website containing articles from a magazine - one page per article.
The articles are sent to me in pdf format and I convert them, normally to rtf format using a utility called ABBYY PDF Transformer 2.0.
Sometimes the footnotes/endnotes are in superscript, sometimes in normal sized text. They are occasionally surrounded by square brackets.
The following macro, after changing the font color of the endnote block to red, inserts the necessary anchors and links, but the notes need to be first surrounded by square brackets. It prompts, having found a number, before making the change. It works well, though sometimes it tries another "pass" through the text, having made the changes, so it would be nice to have a cancel button on the prompt.
BY THE WAY, have not checked if it converts double digit numbers.
Here's the macro:
Sub Footnotesoriginal()
'
' Footnotes Macro
' Macro created 5/27/2007 by Brian O'Gorman
'
Selection.Find.ClearFormat
ting
Selection.Find.Replacement
.ClearForm
atting
Options.AutoFormatAsYouTyp
eReplaceQu
otes = False
With Selection.Find
.Text = "(\[)([0-9]@)(\])"
.Forward = True: .Wrap = wdFindContinue: .format = False
.MatchCase = False: .MatchWholeWord = False: .MatchAllWordForms = False
.MatchSoundsLike = False: .MatchWildcards = True
End With
While Selection.Find.Execute
If MsgBox("Should I replace", vbYesNo) = vbYes Then
If Selection.Font.Color <> vbRed Then
Selection.Find.Replacement
.Text = _
"<a name=""fn\2"" id=""fn\2""></a><a href=""#en\2"">[\2]</a>"
Else
Selection.Find.Replacement
.Text = _
"<a name=""en\2"" id=""en\2""></a><a href=""#fn\2"">[\2]</a>"
End If
Selection.Find.Execute Replace:=wdReplaceOne
Selection.Find.Execute
End If
Wend
End Sub
The MAIN PROBLEM is that the numbers have to be manually surrounded by square brackets first. ALSO, I would like to be able to convert from either superscript numbers (bracketed or not bracketed - there may be brackets already there) or normal numbers (bracketed or not bracketed). I don't mind having to go through numbers like 1984 or 2323232323, though preferably would like confine the scan to two digit numbers as there will almost certainly be less than 100 notes! NB after the conversion, the notes should be in NORMAL CASE, not superscript. and also one should end up with the text on the page showing the notes surrounded by brackets.
The following macro converts superscripts but without prompts. It does not insert the anchors or links:
Sub FootnotesConvertSuperscrip
t()
'
' FootnotesConvertSuperscrip
t Macro
' Macro recorded 08/05/2008 by Brian O'Gorman
'
Selection.Find.ClearFormat
ting
Selection.Find.Replacement
.ClearForm
atting
Selection.Find.Replacement
.Font.Supe
rscript = False
With Selection.Find
.Text = "([0-9])"
.Replacement.Text = "[^&]"
.Forward = True
.Wrap = wdFindContinue
.format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Font.Superscript = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sorry this is so lengthy. Would appreciate anyone's help.
Brian
Start Free Trial