5.4 Footnotes and endnotes

Footnotes and endnotes

Footnotes and endnotes have been the bane of students for generations, but Word makes them reasonably easy to manage. To add either a footnote or an endnote interactively, choose Insert|Footnote from the menu. The dialog shown in Figure 8 appears. As the dialog indicates, by default, footnotes are placed at the bottom of the current page (or, if there s not enough room, at the bottom of the next page). Endnotes appear at the end of the document by default, but they can appear at the end of each section instead.

Figure 8. Adding notes. Both footnotes and endnotes are added using this dialog. It also lets you specify numbering and placement.

For Automation, you work with two collections, Footnotes and Endnotes, and their contained objects, Footnote and Endnote. Document and Range have Footnotes and Endnotes properties that provide access to the two collections. Although accessing the collections through a range lets you look at only the footnotes or endnotes in that range, watch out. Changing properties of the collection there affects all the footnotes or endnotes in the document, not just the ones in that range. The range just grabs a subset of the notes in the collection.

With one exception, the set of properties and methods in the Footnote and Endnote objects is identical, as is the set in the Footnotes and Endnotes collections. You can think of each case as being a subclass of the same parent class. The only difference between them is in the way that they re rendered. In fact, it s possible to convert footnotes to endnotes and endnotes to footnotes. Several methods support the switch.

The only property of Footnote and Endnote worth mentioning is Reference. It provides an object reference to a range containing the number, letter, or other symbol in the main document that points to the note. You can use it to make changes to that symbol, such as enlarging the font size or underlining. (Whether such changes are a good idea is a separate issue.)

Table 6 shows significant properties of the Footnotes and Endnotes collections, while their important methods are listed in Table 7.

Table 6. Specifying footnotes and endnotes. The two collections are structurally identical only their rendering is different.

Property

Type

Description

Location

Numeric

Indicates where the notes appear. For footnotes, use one of these constants:

wdBottomOfPage

0

wdBeneathText

1

For endnotes, use one of these constants:

wdEndOfDocument

1

wdEndOfSection

0

 

NumberingRule

Numeric

Indicates how notes are numbered with respect to page and section breaks.

wdRestartContinuous

0

Number continuously.

wdRestartSection

1

Restart numbers at each section break.

wdRestartPage

2

Restart numbers on each new page.

 

NumberStyle

Numeric

The type of numbering used for the notes. In Word 2000, about 20 styles are provided, but only a few are shown in the Footnote dialog. Others can be set through code, though not all show up properly in all versions of Word.

wdNoteNumberStyleArabic

0

wdNoteNumberStyleLowercaseLetter

4

wdNoteNumberStyleUppercaseLetter

3

wdNoteNumberStyleLowercaseRoman

2

wdNoteNumberStyleUppercaseRoman

1

wdNoteNumberStyleSymbol

9

wdNoteNumberStyleHebrewLetter1

45

 

StartingNumber

Numeric

The number for the first note.

Separator

Object

Pointer to a range containing the separator between the main body of the document and the notes. The separator is usually a short line, but you can add text to it, remove the line, add borders, and even add graphics.

ContinuationSeparatorText

Object

Pointer to a range containing the separator between the main body of the document and the continuation of notes. Appears when notes overflow onto another page. Is usually just a short line, but as with Separator, you can remove the line, add text, add borders, and add graphics.

ContinuationNotice

Object

Pointer to a range containing a message that s displayed when notes overflow onto another page. This message is displayed at the end of the filled page. This is usually empty, but it doesn t have to be. Like the others, you can add text, borders, graphics, and so forth.

Table 7. Manipulating footnotes and endnotes. Collection-level methods let you manage the properties that separate notes from the main body of the document and change note types.

Method

Description

ResetSeparator

Restores the default separator.

ResetContinuationSeparator

Restores the default continuation separator.

ResetContinuationNotice

Restores the default continuation notice.

Convert

Converts all notes in the specified range or document to the other type. That is, if the method is called from a Footnotes collection, it converts the notes to endnotes and adds them to the document s Endnotes collection; if it s called from an Endnotes collection, it converts them to footnotes and adds them to the Footnotes collection. In either case, they re correctly interspersed with existing notes of the other type.

SwapWithEndnotes

Converts all footnotes to endnotes and endnotes to footnotes. This method must be called from a Footnotes collection.

As with other collections, the key to adding new members is the Add method. For footnotes and endnotes, three parameters are required, as follows:

oNotes.Add( oRange [, oReferenceMark [, cText ] ] )

oRange

Object

A range where the note number or symbol is inserted.

oReferenceMark

Object

A range that contains a custom symbol to be used to mark the footnote or endnote. If this parameter is omitted, the note is numbered in accordance with the rule established by NumberingRule and StartingNumber.

cText

Character

The text for the footnote or endnote.

This code creates a range from the first sentence in an existing range, and adds an endnote to it.

#DEFINE wdCharacter 1

oNoteRange = oRange.Sentences[1]

* Back up one character to eliminate the trailing blank

oNoteRange.MoveEnd( wdCharacter, -1 )

* Allow note to be auto-numbered

oRange.Endnotes.Add( oNoteRange, , "This is the new endnote")

In the next example, a footnote is added, and it s given a special marker an asterisk (*) rather than using the default numbering. The note is attached to text that s just been inserted.

#DEFINE wdCollapseEnd 0

oRange.InsertAfter("Be sure to check out WhirlyGig 2000!")

oRange.Collapse( wdCollapseEnd )

oDocument.Footnotes.Add( oRange, "*", ;

"WhirlyGig 2000 is a trademark of MonsterMega Corporation, Ltd.")

 

Copyright 2000 by Tamar E. Granor and Della Martin All Rights Reserved



Microsoft Office Automation with Visual FoxPro
Microsoft Office Automation with Visual FoxPro
ISBN: 0965509303
EAN: 2147483647
Year: 2000
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net