![]() |
|
#1
|
|||
|
|||
|
I need a macro that will count the number of pages in a word document in which footnotes appear?
Thanks |
|
#2
|
||||
|
||||
|
Finding which pages contain footnote references is easy enough, but finding pages where the footnote from a previous page has overflowed onto it is more problematic.
For the former, try: Code:
Sub FindFootnotePages()
Dim i As Long, Rng As Range, j As Long, k As Long, StrPages As String
With ActiveDocument
If .ComputeStatistics(wdStatisticPages) > .Footnotes.Count Then
For i = 1 To .Footnotes.Count
If .Footnotes(i).Range.Information(wdActiveEndPageNumber) > k Then
k = .Footnotes(i).Range.Information(wdActiveEndPageNumber)
j = j + 1
StrPages = StrPages & k & " "
End If
Next
Else
For i = 1 To .ComputeStatistics(wdStatisticPages)
Set Rng = ActiveDocument.GoTo(What:=wdGoToPage, Name:=i)
Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\page")
If Rng.Footnotes.Count > 0 Then
j = j + 1
StrPages = StrPages & i & " "
End If
Next
End If
If j <> 0 Then
StrPages = " references, on pages: " & vbCr & Replace(Trim(StrPages), " ", ", ") & "."
Else
StrPages = "s."
End If
MsgBox "The document: " & .Name & " contains " & j & " footnote" & StrPages
End With
Set Rng = Nothing
End Sub
http://www.vbaexpress.com/forum/show...l=1#post291194
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
That's great. Thanks.
|
|
#4
|
|||
|
|||
|
Any ideas for how to solve the problem of counting footnotes that fall to a subsequent page? Is there a way to identify how many times the Continuation Notice is used in a document? Or, a way to count the number of times the footnote separator is used?
Thanks again. I always get great answers on this site. |
|
#5
|
||||
|
||||
|
Quote:
Possibly, but the code I provided already returns the same count as you'd get for the latter.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#6
|
|||
|
|||
|
Here is the solution I came to. All of the documents I analyze use separators when producing footnotes. The macro checks each page for separator stories and adds the result. Thanks again for your help.
Code:
Dim aPage As Page
Dim j As Long, k As Long, l As Long, m As Long, x As Long, y As Long
j = ActiveDocument.ComputeStatistics(wdStatisticPages) 'Total Page Count
k = 0 'keeps track of current page being analyzed
l = 0 'counts Separator Story
m = 0 'counts Continuation Separator Story
For Each aPage In ActiveDocument.ActiveWindow.ActivePane.Pages
k = k + 1
x = aPage.Rectangles.count 'counts Rectangles on each Page
For y = 1 To x 'cycles through Rectangles on each Page
If aPage.Rectangles.Item(y).RectangleType = wdTextRectangle Then
If aPage.Rectangles.Item(y).Range.StoryType = wdFootnoteSeparatorStory Then
l = l + 1
End If
If aPage.Rectangles.Item(y).Range.StoryType = wdFootnoteContinuationSeparatorStory Then
m = m + 1
End If
End If
Next
Next
Debug.Print l + m
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Display unique values and count the number of child items
|
vthomeschoolmom | Excel | 2 | 07-25-2013 06:17 AM |
page count increases on its own -inserts white pages
|
itsema | Word | 1 | 03-06-2013 12:48 PM |
| Count number of emails from each category | HxG | Outlook | 0 | 09-19-2012 11:55 PM |
| Footnotes: custome number format | btorrance | Word | 2 | 07-30-2012 10:47 AM |
I don t want the footnotes to be numbered continiously in all pages
|
mj2000 | Word | 1 | 10-24-2011 12:43 PM |