DocumentBase.GoTo(Object, Object, Object, Object) Method

Definition

Returns a Range that represents the start position of the specified item, such as a page, bookmark, or field.

public Microsoft.Office.Interop.Word.Range GoTo (ref object what, ref object which, ref object count, ref object name);
member this.GoTo : obj * obj * obj * obj -> Microsoft.Office.Interop.Word.Range
Public Function GoTo (Optional ByRef what As Object, Optional ByRef which As Object, Optional ByRef count As Object, Optional ByRef name As Object) As Range

Parameters

what
Object

The kind of item to which the range or selection is moved. Can be one of the WdGoToItem values.

which
Object

The item to which the range or selection is moved. Can be one of the WdGoToDirection values.

count
Object

The 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 Count value.

name
Object

If the What argument is wdGoToBookmark, wdGoToComment, wdGoToField, or wdGoToObject, this argument specifies a name.

Returns

A Range that represents the start position of the specified item, such as a page, bookmark, or field.

Examples

The following code example uses the GoTo method to get the Microsoft.Office.Interop.Word.Range that represents the start position of the first bookmark in the document. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentGoTo()
{
    object item = Word.WdGoToItem.wdGoToBookmark;
    object whichItem = Word.WdGoToDirection.wdGoToFirst;

    this.GoTo(ref item, ref whichItem, ref missing, ref missing);
}
Private Sub DocumentGoTo()

    Me.GoTo(What:=Word.WdGoToItem.wdGoToBookmark, _
        Which:=Word.WdGoToItem.wdGoToBookmark)
End Sub

Remarks

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

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to