GoTo Method [Word 2007 Developer Reference]

Switch View :
ScriptFree
Document.GoTo Method
Returns a Range object that represents the start position of the specified item, such as a page, bookmark, or field.

Syntax

expression.GoTo(What, Which, Count, Name)

expression   Required. A variable that represents a Document object.

Parameters

NameRequired/OptionalData TypeDescription
WhatOptionalVariantThe kind of item to which the range or selection is moved. Can be one of the WdGoToItem constants.
WhichOptionalVariantThe item to which the range or selection is moved. Can be one of the WdGoToDirection constants.
CountOptionalVariantThe number of the item in the document. The default value is 1. Only positive values are valid. To specify an item that precedes the range or selection, use wdGoToPrevious as the Which argument and specify a value for the Count value.
NameOptionalVariantIf the What argument is wdGoToBookmark, wdGoToComment, wdGoToField, or wdGoToObject, this argument specifies a name. Only positive values are valid. To specify an item that precedes the range or selection, use wdGoToPrevious as the Which argument and specify a value for the Count argument.

Remarks

When you use the GoTo method with the wdGoToGrammaticalError, wdGoToProofreadingError, or wdGoToSpellingError constant, the Range that's returned includes any grammar error text or spelling error text.

Example

This example sets R1 equal to the first footnote reference mark in the active document.

Visual Basic for Applications
If ActiveDocument.Footnotes.Count >= 1 Then
    Set R1 = ActiveDocument.GoTo(What:=wdGoToFootnote, _
        Which:=wdGoToFirst)
    R1.Expand Unit:=wdCharacter
End If