Microsoft KB Archive/109766

{|
 * width="100%"|

WD: WordBasic Examples: View Commands and Functions

 * }

Q109766

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows NT, version 6.0
 * Microsoft Word for Windows 95, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1

-

SUMMARY
This article contains an example that demonstrates the use of the following WordBasic statements and functions:

ViewAnnotations, ViewAnnotations

ViewEndnoteArea ViewEndnoteArea

ViewFieldCodes ViewFieldCodes

ViewFooter ViewFooter

ViewFootnoteArea ViewFootnoteArea

ViewFootnotes ViewFootnotes

ViewHeader ViewHeader This article supplements the information in online Help. To open this Help topic, choose Contents from the Help menu and then choose the "Programming with Microsoft Word" topic.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please see the following page on the World Wide Web:

"http://www.microsoft.com/partner/referral/" For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

"http://support.microsoft.com/directory/overview.asp"

Syntax
ViewAnnotations [On]

ViewAnnotations The ViewAnnotations statement opens or closes the annotation pane. If there are no annotations in the active document, this statement has no effect.

Argument       Explanation ---

On             Specifies whether to open or close the annotation pane: 0(zero)        Opens the annotation pane. 1              Closes the annotation pane. Omitted        Toggles the display of the annotation pane. The ViewAnnotations function returns the following values.

Value          Explanation -          ---

0(zero)      The annotation pane is closed. -1           The annotation pane is open.

Syntax
ViewEndnoteArea [On]

ViewEndnoteArea In normal and outline views, the ViewEndnoteArea statement opens or closes the endnote pane. In page layout view, ViewEndnoteArea moves the insertion point to or from the endnote area. If there are no endnotes in the active document, this statement has no effect.

Argument       Explanation ---

On             Specifies whether to open or close the endnote pane: 0(zero)        In normal and outline views, closes the endnote pane; in page layout view, has no effect. 1              In normal and outline views, opens the endnote pane; in page layout view, moves the insertion point to the endnote area. Omitted        In normal and outline views, toggles the display of                  the endnote pane; in page layout view, moves the insertion point between an endnote and its associated reference mark in the document text. The ViewEndnoteArea function returns the following values.

Value          Explanation -          ---

0 (zero)     The endnote pane is closed. -1           The endnote pane is open.

Syntax
ViewFieldCodes [On]

ViewFieldCodes The ViewFieldCodes statement controls the display of all fields in the active document. The display of field codes is specified by the Field Codes check box on the View tab in the Options dialog box (Tools menu). You can control the display of selected fields with the ToggleFieldDisplay statement.

Argument       Explanation --- On             Specifies how to display fields: 0 (zero)       Displays field results. 1              Displays field codes. Omitted        Toggles the display of fields. The ViewFieldCodes function returns the following values.

Value          Explanation -          ---

0 (zero)     The field results are displayed. -1           The field codes are displayed.

Syntax
ViewFooter

ViewFooter The ViewFooter statement switches the active document to page layout view, positions the insertion point in the footer area, and then displays the Header And Footer toolbar. If the Header And Footer toolbar is already displayed, ViewFooter hides it and moves the insertion point to the document area.

The ViewFooter function returns the following values.

Value          Explanation -          ---  0(zero)       The insertion point is not in the footer area. -1           The insertion point is in the footer area.

Syntax
ViewFootnoteArea [On]

ViewFootnoteArea The ViewFootnoteArea statement opens or closes the footnote pane (in normal view) and moves the insertion point between the document area and the footnote area. If there are no footnotes in the active document, this statement has no effect.

Argument       Explanation --- On             Specifies whether to display the footnote area: 1              Opens the footnote pane (in normal view) and moves the insertion point to the footnote area. 0(zero)        Closes the footnote pane (in normal view) and moves the insertion point to the appropriate reference mark in the document area. Omitted        Toggles the display of the footnote pane (in normal                  view) and moves the insertion point from the document area to the footnote area, or vice versa. The ViewFootnoteArea function returns the following values.

Value          Explanation -          ---  0(zero)       The footnote pane is closed. -1           The footnote pane is open.

Syntax
ViewFootnotes

ViewFootnotes In normal view, the ViewFootnotes statement opens or closes the footnote pane or endnote pane according to the following rules:


 * If the document contains footnotes, opens the footnote pane.
 * If the document contains endnotes, but no footnotes, opens the endnote pane.
 * If the footnote pane or endnote pane is already open, closes the pane.

In page layout view, ViewFootnotes moves the insertion point according to the following rules:


 * If the document has only footnotes, moves the insertion point to the footnote area; if it has only endnotes, moves the insertion point to the endnote area.
 * If the document has both footnotes and endnotes, displays a dialog box that asks the user to choose between the footnote and endnote area.
 * If the insertion point is already in a footnote or endnote area, moves the insertion point to the document area.

If the document contains no footnotes or endnotes, ViewFootnotes has no effect.

The ViewFootnotes function returns the following values.

Value          Explanation -          ---  0(zero)       Neither the footnote nor endnote pane is open. -1           Either the footnote or endnote pane is open.

Syntax
ViewHeader

ViewHeader The ViewHeader statement switches the active document to page layout view, positions the insertion point in the header area, and then displays the Header And Footer toolbar. If the Header And Footer toolbar is already displayed, ViewHeader hides it and moves the insertion point to the document area.

The ViewHeader function returns the following values.

Value          Explanation -          ---  0(zero)       The insertion point is not in the header area. -1           The insertion point is in the header area.

Example
This macro demonstrates various View commands; each one of the case statements can be used by itself as a test or cleansheet macro.

  Sub MAIN On Error Goto bye Begin Dialog UserDialog 554, 228, "Test Some View Commands" OKButton 10, 201, 240, 21 CancelButton 277, 201, 240, 21 OptionGroup .OptionGroup1 OptionButton 10, 74, 511, 16, "Check this to demo the \         ViewAnnotation command and function", .OptionButton1 OptionButton 10, 91, 529, 16, "Check this to demo the \         ViewEndnoteArea command and function", .OptionButton2 OptionButton 10, 108, 512, 16, "Check this to demo the \         ViewFieldCodes command and function", .OptionButton3 OptionButton 10, 125, 477, 16, "Check this to demo the \         ViewFooter command and function", .OptionButton4 OptionButton 10, 142, 533, 16, "Check this to demo the \         ViewFootnoteArea command and function", .OptionButton5 OptionButton 10, 159, 507, 16, "Check this to demo the \         ViewFootnotes command and function", .OptionButton6 OptionButton 10, 176, 484, 16, "Check this to demo the \         ViewHeader command and function", .OptionButton7 Text 10, 6, 506, 53, "This macro demonstrates the \         ViewAnnotations, ViewAnnotations, ViewEndnoteArea \          ViewEndnoteArea, ViewFieldCodes ViewFieldCodes, \          ViewFooter ViewFooter, ViewFootnoteArea ViewFootnoteArea, \          ViewFootnotes ViewFootnotes, ViewHeader", .Text1 Text 10, 57, 328, 13, "and ViewHeader commands and \         functions", .Text2 End Dialog Dim dlg As UserDialog n = Dialog(dlg) If n = 0 Then Goto bye Select Case Dlg.Optiongroup1 Case 0 InsertAnnotation    ' To ensure an annotation present ViewAnnotations     ' closes Annotation pane MsgBox "An annotation should now be added and the pane closed" If ViewAnnotations = 0 Then ViewAnnotations MsgBox "Annotation pane should now be open" ViewAnnotations MsgBox "Annotation pane is now closed, and the demo is now \            over" Case 1 InsertFootnote .NoteType = 1     'To ensure a footnote present ViewEndnoteArea                  'closes EndnoteArea pane MsgBox "An endnote is now added and the pane closed" If ViewEndnoteArea = 0 Then ViewEndnoteArea MsgBox "EndnoteArea pane should now be open" ViewEndnoteArea MsgBox "EndnoteArea pane is now closed, and the demo is now \            over" Case 2 InsertDateTime .InsertAsField = 1' To ensure a field present ViewFieldCodes 0                ' Displays Field results MsgBox "The results of a date field should now be seen" ViewFieldCodes - 1 MsgBox "Fieldcode should now be visible, demo done" Case 3 ViewFooter MsgBox "The Header Footer toolbar should now be toggled \            On\Off and the insertion point inside the footer" ViewFooter MsgBox "The Header Footer toolbar should be toggled On\Off" Case 4 InsertFootnote .NoteType = 0     'To ensure a footnote present ViewFootnoteArea                 'closes FootnoteArea pane MsgBox "A footnote is now added and the pane closed" If ViewFootnoteArea = 0 Then ViewFootnoteArea MsgBox "FootnoteArea pane should now be open" ViewFootnoteArea MsgBox "FootnoteArea pane is now closed, and the demo is now \            over" Case 5 ViewFootnotes MsgBox "Footnote pane and or endnote pane now open " ViewFootnotes MsgBox "Footnote pane and or endnote pane is now closed, end \            demo " Case 6 ViewHeader MsgBox "The Header Footer toolbar should now be toggled On\Off" ViewHeader MsgBox "The Header Footer toolbar once again should be \            toggled On\Off" End Select Bye: ' NOTE: This line must be left aligned. End Sub Additional query words:

Keywords : wordnt kbmacroexample winword ntword macword word6 word7 word95

Issue type : kbhowto

Technology : kbWordSearch kbWordWSearch kbWordMSearch