Advertisement

05.13.2008 at 05:02AM PDT, ID: 23397383
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

Macro to insert anchors and links for footnotes and endnotes

Asked by bogorman in Visual Basic Programming, Microsoft Word

Tags: ,

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.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Options.AutoFormatAsYouTypeReplaceQuotes = 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 FootnotesConvertSuperscript()
'
' FootnotesConvertSuperscript Macro
' Macro recorded 08/05/2008 by Brian O'Gorman
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Superscript = 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
 
 
[+][-]05.13.2008 at 09:45AM PDT, ID: 21556862

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.13.2008 at 09:55AM PDT, ID: 21556964

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Basic Programming, Microsoft Word
Tags: Visual Basic 6.5 (Word 2003), IE7/Mozilla
Sign Up Now!
Solution Provided By: bogorman
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628