Share via


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)

Syntax

'Declaration
Public Function GoTo ( _
    ByRef what As Object, _
    ByRef which As Object, _
    ByRef count As Object, _
    ByRef name As Object _
) As Range
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.
  • 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.

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.

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.

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 Sub DocumentGoTo()

    Me.GoTo(What:=Word.WdGoToItem.wdGoToBookmark, _
        Which:=Word.WdGoToItem.wdGoToBookmark)
End Sub
private void DocumentGoTo()
{
    object item = Word.WdGoToItem.wdGoToBookmark;
    object whichItem = Word.WdGoToDirection.wdGoToFirst;

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

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace