Extracting endnotes/footnotes from main document

J

jimboid

Hi there - first-timer here!

I've been asked to tidy up a very long document. It's currently in the form:

Paragraph of content [variable length, always two or more lines]
Blank line
Source of above paragraph [always one line only]
Blank line
and repeat...

I need to put a sequential superscripted number on the end of each
paragraph, and move all the Source lines to become correspondingly linked
footnotes or endnotes. The Source remarks have no distinguishing features
other than being single lines! I'm guessing I need to do this manually, but
wondered if anyone knows of a macro or similar automated method.

Any assistance is appreciated.

Jimboid
 
P

Pesach Shelnitz

Hi Jimboid,

Make sure that the last source has exactly one blank line after it and try
this.

Sub PutSourcesInFootnotes()
Dim myRange As Range
Dim i As Long

With ActiveDocument
For i = 1 To .Paragraphs.Count / 4
Set myRange = .Paragraphs(i).Range
myRange.Collapse Direction:=wdCollapseEnd
myRange.MoveStart Unit:=wdCharacter, Count:=-1
myRange.MoveEnd Unit:=wdCharacter, Count:=-1
.Paragraphs(i).Range.Footnotes.Add _
Range:=myRange, _
Text:=.Paragraphs(i + 2).Range.Text
.Paragraphs(i + 1).Range.Delete
.Paragraphs(i + 1).Range.Delete
.Paragraphs(i + 1).Range.Delete
Next
End With
End Sub

This macro generates footnotes, but it can be modified to generate endnotes.
 
J

jimboid

Wow, thanks Pesach - that was quick. I am setting up an extract from the
document for testing and shall be sure to let you know how I get on.

Best wishes

Jimboid



Pesach Shelnitz said:
Hi Jimboid,

Make sure that the last source has exactly one blank line after it and try
this.

Sub PutSourcesInFootnotes()
Dim myRange As Range
Dim i As Long

With ActiveDocument
For i = 1 To .Paragraphs.Count / 4
Set myRange = .Paragraphs(i).Range
myRange.Collapse Direction:=wdCollapseEnd
myRange.MoveStart Unit:=wdCharacter, Count:=-1
myRange.MoveEnd Unit:=wdCharacter, Count:=-1
.Paragraphs(i).Range.Footnotes.Add _
Range:=myRange, _
Text:=.Paragraphs(i + 2).Range.Text
.Paragraphs(i + 1).Range.Delete
.Paragraphs(i + 1).Range.Delete
.Paragraphs(i + 1).Range.Delete
Next
End With
End Sub

This macro generates footnotes, but it can be modified to generate endnotes.

--
Hope this helps,
Pesach Shelnitz


jimboid said:
Hi there - first-timer here!

I've been asked to tidy up a very long document. It's currently in the form:

Paragraph of content [variable length, always two or more lines]
Blank line
Source of above paragraph [always one line only]
Blank line
and repeat...

I need to put a sequential superscripted number on the end of each
paragraph, and move all the Source lines to become correspondingly linked
footnotes or endnotes. The Source remarks have no distinguishing features
other than being single lines! I'm guessing I need to do this manually, but
wondered if anyone knows of a macro or similar automated method.

Any assistance is appreciated.

Jimboid
 
J

jimboid

Hello again Pesach - It works perfectly! Thank you so much. My goodness,
that will save me many hours of work!

The only tweaking I needed to do was in the test document itself because of
Word's strict interpretation of paragraphs, as there were some "carriage
returns" (=new paragraph) instead of manual line breaks. Some fancy moves
with "Replace all" soon got everything in the right format.

The "customer" (my father) has now expressed a preference for endnotes
rather than footnotes so, as you indicated, I changed the code accordingly &
works like a dream. Short & sweet.

Nice one - I owe you a beer if you're ever in England!

Jimboid

Pesach Shelnitz said:
Hi Jimboid,

Make sure that the last source has exactly one blank line after it and try
this.

Sub PutSourcesInFootnotes()
Dim myRange As Range
Dim i As Long

With ActiveDocument
For i = 1 To .Paragraphs.Count / 4
Set myRange = .Paragraphs(i).Range
myRange.Collapse Direction:=wdCollapseEnd
myRange.MoveStart Unit:=wdCharacter, Count:=-1
myRange.MoveEnd Unit:=wdCharacter, Count:=-1
.Paragraphs(i).Range.Footnotes.Add _
Range:=myRange, _
Text:=.Paragraphs(i + 2).Range.Text
.Paragraphs(i + 1).Range.Delete
.Paragraphs(i + 1).Range.Delete
.Paragraphs(i + 1).Range.Delete
Next
End With
End Sub

This macro generates footnotes, but it can be modified to generate endnotes.

--
Hope this helps,
Pesach Shelnitz


jimboid said:
Hi there - first-timer here!

I've been asked to tidy up a very long document. It's currently in the form:

Paragraph of content [variable length, always two or more lines]
Blank line
Source of above paragraph [always one line only]
Blank line
and repeat...

I need to put a sequential superscripted number on the end of each
paragraph, and move all the Source lines to become correspondingly linked
footnotes or endnotes. The Source remarks have no distinguishing features
other than being single lines! I'm guessing I need to do this manually, but
wondered if anyone knows of a macro or similar automated method.

Any assistance is appreciated.

Jimboid
 

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