Solved

Copy footnote text in new document

Posted on 2009-03-30
5
613 Views
Last Modified: 2012-06-21
Dear Experts:
Below macro copies all footnotes and pastes them into a new document. The macro runs just fine. There is a small drawback to the pasted text since the original footnote reference numbers are lost and all the pasted footnotes have got the number 1. I do not care about that.

Now I got a document where each time a new section is started, the footnotes will start with number one (1) again.
The macro should be rewritten so that whenever the footnote number restarts, the target document in which the footnotes are copied should list the new section number before the copied footnotes. Example:

Section 1:
(1) sample text 1
(1) sample text 2
(1) sample text 3
Section 2:
(1) sample footnote text 4
(1) sample footnote text 5
(1) sample footnote text 6
(1) sample footnote text 7
Section 3:
(1) sample footnote text 8
etc.  

I wonder whether this is possible? Help is much appreciated. Thank you very much in advance. Regards, Andreas

Sub CopyFNTextInNewDoc()
 

If MsgBox("This macro copies all footnotes and paste them into a new document" & vbCrLf & _

"Would you like to continue?", vbYesNo, "Copying all footnotes into a new document") = vbNo Then

Exit Sub
 

ElseIf ActiveDocument.Footnotes.count = 0 Then

MsgBox "There are no footnotes in the current document", vbInformation

End If
 

  Dim oDoc As Document, nDoc As Document

  Set oDoc = ActiveDocument

  Set nDoc = Documents.Add(Template:=oDoc.AttachedTemplate.FullName)

  nDoc.Content.FormattedText = oDoc.StoryRanges(wdFootnotesStory).FormattedText

End Sub

Open in new window

0
Comment
Question by:AndreasHermle
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:DonQuiyote
ID: 24027440
Try this instead. If the footer numbers play up, why not insert new sections as well?
  Dim i As Integer

  For i = 1 To oDoc.Sections.count

  nDoc.Content.InsertAfter oDoc.Sections(1).Footers(wdHeaderFooterPrimary).Range.FormattedText

  Next i

Open in new window

0
 

Author Comment

by:AndreasHermle
ID: 24036254
Dear DonQuiyote:
thanks for the swift help. This is just to tell you that it is gonna be tomorrow till I will have tested it.
Regards, Andreas
0
 

Author Comment

by:AndreasHermle
ID: 24041579
Hi DonQuiyote:

I am afraid to tell you that there must be a misunderstanding on your side. I am talking about footnotes that need to be copied and pasted into a new document (along with their respective section no.) and not 'footers' as you meant.

Regards, Andreas
0
 
LVL 1

Accepted Solution

by:
DonQuiyote earned 500 total points
ID: 24046124
That's no problem, but we'll just have to search repeatedly for each section:
Sub CopyFNTextInNewDoc()

If MsgBox("This macro copies all footnotes and paste them into a new document" & vbCrLf & _

"Would you like to continue?", vbYesNo, "Copying all footnotes into a new document") = vbNo Then

Exit Sub

 

ElseIf ActiveDocument.Footnotes.count = 0 Then

MsgBox "There are no footnotes in the current document", vbInformation

End If

 

    Dim oDoc As Document, nDoc As Document

    Set oDoc = ActiveDocument

    Set nDoc = Documents.add(template:=oDoc.AttachedTemplate.FullName)

    

    Dim f, s, ff As Footnote, ss As Section, i As Integer

    With nDoc.Content

    For Each s In oDoc.Sections

        Set ss = s ' not necessary but enables autocomplete

        .InsertAfter "Section " & ss.Index & ":" + vbCr

        For Each f In oDoc.Footnotes

            Set ff = f

            If ff.Reference.InRange(ss.Range) Then

                .InsertAfter ff.Index & ". " + ff.Range.FormattedText + vbCr

            End If

        Next

    Next

    End With

    

End Sub

Open in new window

0
 

Author Closing Comment

by:AndreasHermle
ID: 31564272
Dear DQ: very good job. Thank you for your terrific help. Regards, Andreas
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now