Extract just footer macro for Word!

U

umchemist

Hi Everyone!

Can anyone help me with the macro below? I would like it to simply extract
all the footers in the document and paste them into a new word document???
Each footer would be a new line, essentially assembling a list of all the
footers. What I have so far unfortunately does not work and complains about
syntax errors.....can anyone please help me ???

Sub PullMe()
Dim lCount As Long
Dim sEnd As String
Dim oDoc As Document

sEnd = "Endnotes" & vbCrLf
For lCount = 1 To ActiveDocument.Endnotes.Count
sEnd = sEnd & lCount & vbTab &
ActiveDocument.Endnotes(lCount).Range.Text & vbCrLf
Next lCount

sEnd = sEnd & "Footnotes" & vbCrLf
For lCount = 1 To ActiveDocument.Footnotes.Count
sEnd = sEnd & lCount & vbTab &
ActiveDocument.Footnotes(lCount).Range.Text & vbCrLf
Next lCount

Set oDoc = Documents.Add
oDoc.Range.Text = sEnd

End Sub
 
G

Greg Maxey

Seems to me that what you have so far is concerned with endnotes and
footnotes, not footers:

Sub ScratchMaco()
Dim oDoc1 As Document
Dim oDoc2 As Document
Set oDoc1 = ThisDocument
Set oDoc2 = Documents.Add
Dim i As Long
Dim j As Long
For i = 1 To oDoc1.Sections.Count
For j = 1 To 3
oDoc2.Range.InsertAfter oDoc1.Sections(i).Footers(j).Range.Text
Next j
Next i
End Sub
 
F

Fumei2 via OfficeKB.com

Or....

Sub CopyFooters()
Dim oHF As HeaderFooter
Dim oSection As Section
Dim ThisDoc As Document
Dim ThatDoc As Document

Set ThisDoc = ActiveDocument
Set ThatDoc = Documents.Add

For Each oSection In ThisDoc.Sections
For Each oHF In oSection.Footers
ThatDoc.Range.InsertAfter oHF.Range.Text
Next
Next
End Sub

Although this is really not significantly different from Greg's code. It
just does not use counters.

Greg said:
Seems to me that what you have so far is concerned with endnotes and
footnotes, not footers:

Sub ScratchMaco()
Dim oDoc1 As Document
Dim oDoc2 As Document
Set oDoc1 = ThisDocument
Set oDoc2 = Documents.Add
Dim i As Long
Dim j As Long
For i = 1 To oDoc1.Sections.Count
For j = 1 To 3
oDoc2.Range.InsertAfter oDoc1.Sections(i).Footers(j).Range.Text
Next j
Next i
End Sub
Hi Everyone!
[quoted text clipped - 26 lines]
 
F

Fumei2 via OfficeKB.com

I just want to add that in both Greg's and my code, the order the footer
contents are inserted (by Section) is:

Primary
FirstPage
EvenPage

Further, in both cases, "blank" footers for FirstPage and Even Page are
inserted. In other words, even if you are not using FirstPage or EvenPage,
their contents ARE copied - as "empty" paragraphs. So if you were only using
Primary (you do NOT have FirstPage or Odd/Even checked), and the - say you
have two Sections...with

Footer Section 1
Footer Section 2

What you end up with is:

Footer Section 1 - this is Primary
"empty" paragraph; this is FirstPage
"empty" paragraph; this is EvenPage
Footer Section 2
"empty" paragraph; this is FirstPage
"empty" paragraph; this is EvenPage






Or....

Sub CopyFooters()
Dim oHF As HeaderFooter
Dim oSection As Section
Dim ThisDoc As Document
Dim ThatDoc As Document

Set ThisDoc = ActiveDocument
Set ThatDoc = Documents.Add

For Each oSection In ThisDoc.Sections
For Each oHF In oSection.Footers
ThatDoc.Range.InsertAfter oHF.Range.Text
Next
Next
End Sub

Although this is really not significantly different from Greg's code. It
just does not use counters.
Seems to me that what you have so far is concerned with endnotes and
footnotes, not footers:
[quoted text clipped - 18 lines]
 
U

umchemist

Oh dang it, I meant footnotes...

Yes the code is designed to extract footnotes and endnotes....anyway to get
it working to copy them into a new document?
 

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