Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GoTo Method
Collapse the table of content
Expand the table of content

DocumentBase.GoTo Method

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

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public Range GoTo(
	ref Object what,
	ref Object which,
	ref Object count,
	ref Object name
)

Parameters

what
Type: System.Object

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

which
Type: System.Object

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

count
Type: System.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
Type: System.Object

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

Return Value

Type: Microsoft.Office.Interop.Word.Range
A Range that represents the start position of the specified item, such as a page, bookmark, or field.

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.

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);
}

Show:
© 2015 Microsoft