Метод goto vba word

Обновлено: 04.07.2024

Moves the insertion point to the character position immediately preceding the specified item, and returns a Range object (except for the wdGoToGrammaticalError, wdGoToProofreadingError, or wdGoToSpellingError constant).

Syntax

expression. GoTo ( _What_ , _Which_ , _Count_ , _Name_ )

expression Required. A variable that represents a Selection object.

Parameters

Name Required/Optional Data type Description
What Optional Variant The kind of item to which the range or selection is moved. Can be one of the WdGoToItem constants.
Which Optional Variant The item to which the range or selection is moved. Can be one of the WdGoToDirection constants.
Count Optional Variant 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 Optional Variant If the What argument is wdGoToBookmark, wdGoToComment, wdGoToField, or wdGoToObject, this argument specifies a name.

Return value

The Range that is now selected.

Remarks

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

Examples

The following examples are functionally equivalent; they both move the selection to the first heading in the document.

The following example moves the selection to the fourth line in the document.

The following example moves the selection up two lines.

The following example moves to the next DATE field.

This example moves the selection to the first cell in the next table.

This example moves the insertion point just before the fifth endnote reference mark in the active document.

This example moves the selection down four lines.

This example moves the selection back two pages.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

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

Name Required/Optional Data type Description
What Optional Variant The kind of item to which the range or selection is moved. Can be one of the WdGoToItem constants.
Which Optional Variant The item to which the range or selection is moved. Can be one of the WdGoToDirection constants.
Count Optional Variant 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 value for the Count value.
Name Optional Variant If 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.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

Возвращает объект Range, который представляет стартовую позицию указанного элемента, например страницу, закладки или поле.

Синтаксис

выражение. GoTo ( _What_ , _Which_ , _Count_ , _Name_ )

выражение (обязательно). Переменная, представляюная объект Document.

Параметры

Имя Обязательный или необязательный Тип данных Описание
What Необязательный Variant Тип элемента, в который перемещается диапазон или выбор. Может быть одной из констант WdGoToItem.
Which Необязательный Variant Элемент, в который перемещается диапазон или выбор. Может быть одним из констант WdGoToDirection.
Count Необязательный Variant Количество элемента в документе. Значение по умолчанию равно 1. Допустимы только положительные значения. Чтобы указать элемент, предшествующий диапазону или выбору, используйте wdGoToPrevious в качестве аргумента Which и укажите значение для значения Count.
Name Необязательно заполнять. Variant Если аргумент wdGoToBookmark, wdGoToComment, wdGoToField или wdGoToObject, этот аргумент указывает имя. Допустимы только положительные значения. Чтобы указать элемент, предшествующий диапазону или выбору, используйте wdGoToPrevious в качестве аргумента Which и укажите значение аргумента Count.

Примечания

При использовании метода GoTo с помощью wdGoToGrammaticalError, wdGoToProofreadingError или константы wdGoToSpellingError диапазон включает любой текст грамматики или текст ошибки орфографии.

Пример

В этом примере R1 устанавливается в качестве первого эталонного знака сноски в активном документе.

См. также

Поддержка и обратная связь

Есть вопросы или отзывы, касающиеся Office VBA или этой статьи? Руководство по другим способам получения поддержки и отправки отзывов см. в статье Поддержка Office VBA и обратная связь.

Возвращает объект Range, который представляет стартовую позицию указанного элемента, например страницу, закладки или поле.

Синтаксис

выражение (обязательно). Переменная, представляюная объект Range.

Параметры

Имя Обязательный или необязательный Тип данных Описание
What Необязательный Variant Тип элемента, в который перемещается диапазон. Может быть одной из констант wdGoToItem.
Which Необязательный Variant Элемент, в который перемещается диапазон. Может быть одним из констант wdGoToDirection.
Count Необязательный Variant Количество элемента в документе. Значение по умолчанию равно 1. Допустимы только положительные значения. Чтобы указать элемент, предшествующий диапазону, используйте wdGoToPrevious в качестве аргумента Which и укажите значение Count.
Name Необязательно заполнять. Variant Если аргумент wdGoToBookmark, wdGoToComment, wdGoToField или wdGoToObject, этот аргумент указывает имя. Допустимы только положительные значения. Чтобы указать элемент, предшествующий диапазону, используйте wdGoToPrevious в качестве аргумента Which и укажите значение Count.

Заметки

В следующем примере диапазон перемещается вверх по двум строкам.

Следующий пример перемещается в следующее поле DATE.

В следующем примере диапазон перемещается на четвертую строку в документе.

Следующие примеры функционально эквивалентны; они оба перемещают диапазон к первому заголовку в документе.

При использовании метода GoTo с помощью wdGoToGrammaticalError, wdGoToProofreadingError или константы wdGoToSpellingError диапазон, возвращаемый, включает любой текст ошибки грамматики или текст ошибки орфографии.

Пример

В этом примере перед пятой эталонной меткой в активном документе перемещается точка вставки.

В этом примере R1 устанавливается в качестве первого эталонного знака сноски в активном документе.

Поддержка и обратная связь

Есть вопросы или отзывы, касающиеся Office VBA или этой статьи? Руководство по другим способам получения поддержки и отправки отзывов см. в статье Поддержка Office VBA и обратная связь.

Читайте также: