Footnotes and Endnotes, dealing with them from older programs in MS Word

  • Thread starter Bill From DegiCank
  • Start date
B

Bill From DegiCank

Anyone have any tips on dealing with footnotes from older programs
where the footnotes are not encoded as footnotes, and easily converting
them to proper footnotes in Word?

Example would be a 50 page document with superscript numbers throughout
that represent reference's, and taking that into word and modifying /
reformatting the document so that the page layout changes, but the
footnotes, go where ever they please.

Does anyone know of any tools that can handle this type of situation?
 
M

macropod

Hi Bill,

Below is a macro to process your footnotes *and* retain any formatting (eg
bold/italic/underline).

The macro assumes the footnotes will all be grouped together, and requires
you to select them before running the code.

The macro also assumes you'll be using the "Footnote Text" style footnotes.
If not, you can simply change it in the line:
.Style = "Footnote Text"

The other important point to note is that, as coded, the macro only works
with single-paragraph footnotes. If you have any multi-paragraph footnotes,
you can get around that issue by changing their internal paragraph markers
to line feeds (i.e. Shift-Enter).

As it runs, the macro shows its progress on the status bar.

Sub ReLinkFootNotes()
Dim i As Integer
Dim j As Integer
Application.ScreenUpdating = False
With Selection
.Bookmarks.Add Range:=Selection.Range, Name:="FootNotes"
j = 0
For i = 1 To .Paragraphs.Count
If .Paragraphs(i).Range.Words(1) = j + 1 Then
j = j + 1
End If
Next i
End With
For i = 1 To j
StatusBar = "Finding Footnote Location: " & i
ActiveDocument.Select
With Selection.Find
.Forward = True
.Font.Superscript = True
.Text = i
.MatchWholeWord = False
.Execute
If .Found = True Then
.Parent.Select
With Selection
.Delete
.Footnotes.Add Range:=Selection.Range, Text:=""
End With
End If
End With
Next i
With ActiveDocument.Bookmarks("FootNotes").Range
For i = 1 To j
StatusBar = "Transferring Footnote: " & i
With .Paragraphs(1).Range
.Cut
With ActiveDocument.Footnotes(i).Range
.Paste
.Words(1).Delete
.Characters(.Characters.Count).Delete
.Style = "Footnote Text"
End With
End With
Next i
On Error Resume Next
.Bookmarks("FootNotes").Delete
End With
Application.ScreenUpdating = True
End Sub

How the code works:
.. Take the selected range of footnotes and bookmark them.
.. Count the number of bookmarked paragraphs with sequential numbers,
starting at '1'.
.. Find the corresponding superscripted sequential numbers in the document.
.. Turn matched superscripted sequential numbers into empty footnotes.
.. Cut the bookmarked footnote paragraphs and paste them into the empty
footnotes.
.. Delete the first word (footnote number) and last character (duplicate para
mark) from each footnote and apply the footnote style.
.. Delete the bookmark.

Cheers
 
B

Bill From DegiCank

I get a run time error 13 when I try the macro, most likely somthing
I'm doing wrong.

Here's what show's up when I debug:

If .Paragraphs(i).Range.Words(1) = j + 1 Then

Here's a little more about the project I'm working on if anyone is
intersted.

I get a PDF from this site:
http://www.ca9.uscourts.gov
clicking opinions brings you here:
http://www.ca9.uscourts.gov/ca9/new...by+date?OpenView&Start=1&Count=100&Expand=1.1
For this particular example lets look at this case:
06/01/06 03-56712 J HYDRICK V DEMORALES
http://www.ca9.uscourts.gov/ca9/new...825717F0076B726/$file/0356712.pdf?openelement

Long story short I've taken the PDF and converted it to a Word DOC. I'm
putting them both on my homepage for ease of use here:
http://degicank.com/doc/

I figured the best way to go about this is to write a macro which i'm
working on which brings me to this issue. In the macro I'm working I
cannot find the superscript text. For example I want to just find the
superscript 1, delete it and place a reference there for a footnote.
When I try to record the macro it will go after any number and ignores
the superscript effect.

Anyone know how to make a macro that will specifically find a
superscript font?

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 6/2/2006 by William Speers
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "1"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
With Selection
With .FootnoteOptions
.Location = wdBottomOfPage
.NumberingRule = wdRestartContinuous
.StartingNumber = 1
.NumberStyle = wdNoteNumberStyleArabic
End With
.footnotes.Add Range:=Selection.Range, Reference:=""
End With
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "2"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
With Selection
With .FootnoteOptions
.Location = wdBottomOfPage
.NumberingRule = wdRestartContinuous
.StartingNumber = 1
.NumberStyle = wdNoteNumberStyleArabic
End With
.footnotes.Add Range:=Selection.Range, Reference:=""
End With
Selection.Find.ClearFormatting
With Selection.Find
.Text = "3"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
With Selection
With .FootnoteOptions
.Location = wdBottomOfPage
.NumberingRule = wdRestartContinuous
.StartingNumber = 1
.NumberStyle = wdNoteNumberStyleArabic
End With
.footnotes.Add Range:=Selection.Range, Reference:=""
End With
Selection.HomeKey Unit:=wdStory
End Sub
 
M

macropod

Hi Bill,

That sounds like your selected footnote range might have a numbered para
with no text or an un-numbered paragraph. I didn't allow for the former and
you'll recall I mentioned the latter, and how to deal with it, in my
previous post.

Cheers
 
C

captaingeek

Been banging my head off the wall here trying to figure this out with
no luck.

Macropod, do you have an example paragraph I could run this on?

Anyway, by reading the macro you made I was able to figure out how to
find superscript font's.

With this knowledge, and the rest of your macro I may be able to create
a better macro that will meet our needs.

I will let you know.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 6/5/2006 by William Speers
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "1"
.Replacement.Text = ""
.Forward = True
.Font.Superscript = True
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
 
M

macropod

Hi Bill,

The code I posted works fine on a document that has the footnotes grouped at
the end and selected, as described in my original post. The document you're
converting from pdf (not a document "with footnotes from older programs" as
you originally described it) already has the footnotes formatted as such at
the bottom of each page.

Finding superscripted text in the document and converting it to a Word
footnote link is trivial, and my code shows you how to do that.

Without selecting the footnote text, getting Word to recognise where the
corresponding footnote for any superscripted body text sits in the document
can be problematic, especially if the footnote continues onto the next page,
as it does with your footnote 3, for example. That's why my code works from
the premise that the footnotes were grouped at the end and selected.

If you can at least:
.. put the whole of each footnote together in one paragraph; and
.. make sure each footnote has a space separating the footnote number and the
first word of the footnote,
then a few minor modifications to my code should get you under way.

The modifications would be to:
.. add a new variable near the top:
Dim k As Integer
.. change the line:
j = 0
to
k = Paragraphs(1).Range.Words(1) - 1
j = k
.. change the two lines
For i = 1 To j
to
For i = k + 1 To j

With these modifications, the macro will process all footnotes in the
selection starting from whatever number the first selected footnote
paragraph starts with.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top