Método Selection. GoTo (Word)Selection.GoTo method (Word)
Move o ponto de inserção para a posição de caractere imediatamente anterior ao item especificado e retorna um objeto Range (exceto para a constante constante wdGoToGrammaticalError, wdGoToProofreadingErrorou wdGoToSpellingError ).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).
SintaxeSyntax
expression.expression. GoTo
( _What_
, _Which_
, _Count_
, _Name_
)GoTo
( _What_
, _Which_
, _Count_
, _Name_
)
expressão Obrigatório.expression Required. Uma variável que representa um objeto Selection.A variable that represents a Selection object.
ParâmetrosParameters
NomeName | Obrigatório/OpcionalRequired/Optional | Tipo de dadosData type | DescriçãoDescription |
---|---|---|---|
WhatWhat | OpcionalOptional | VariantesVariant | O tipo de item para o qual o intervalo ou a seleção é movido(a).The kind of item to which the range or selection is moved. Pode ser uma das constantes WdGoToItem.Can be one of the WdGoToItem constants. |
WhichWhich | OpcionalOptional | VariantesVariant | O item para o qual o intervalo ou a seleção é movido(a).The item to which the range or selection is moved. Pode ser uma das constantes WdGoToDirection.Can be one of the WdGoToDirection constants. |
CountCount | OpcionalOptional | VariantesVariant | O número do item no documento.The number of the item in the document. O valor padrão é 1.The default value is 1. Apenas valores positivos são válidos.Only positive values are valid. Para especificar um item que precede o intervalo ou seleção, use wdGoToPrevious como o argumento que e especifique um valor de contagem.To specify an item that precedes the range or selection, use wdGoToPrevious as the Which argument and specify a Count value. |
NameName | OpcionalOptional | VariantesVariant | Se o argumento What for wdGoToBookmark, wdGoToComment, wdGoToField ou wdGoToObject, este argumento especificará um nome.If the What argument is wdGoToBookmark, wdGoToComment, wdGoToField, or wdGoToObject, this argument specifies a name. |
Valor de retornoReturn value
O intervalo que agora está selecionado.The Range that is now selected.
ComentáriosRemarks
Quando você usa o método GoTo com a constante wdGoToGrammaticalError, wdGoToProofreadingError ou wdGoToSpellingError constante, o objeto Range retornado inclui qualquer texto de erro gramatical ou o texto de erro de ortografia.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.
ExemplosExamples
Os exemplos a seguir são funcionalmente equivalentes, ambos movem a seleção para o primeiro título do documento.The following examples are functionally equivalent; they both move the selection to the first heading in the document.
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToFirst
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToAbsolute, Count:=1
O exemplo a seguir move a seleção para a quarta linha do documento.The following example moves the selection to the fourth line in the document.
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=4
O exemplo a seguir move a seleção duas linhas para cima.The following example moves the selection up two lines.
Selection.GoTo What:=wdGoToLine, Which:=wdGoToPrevious, Count:=2
O exemplo a seguir vai para o próximo campo DATE.The following example moves to the next DATE field.
Selection.GoTo What:=wdGoToField, Name:="Date"
Este exemplo move a seleção para a primeira célula da próxima tabela.This example moves the selection to the first cell in the next table.
Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext
Este exemplo move o ponto de inserção para imediatamente antes da quinta marca de nota de fim do documento ativo.This example moves the insertion point just before the fifth endnote reference mark in the active document.
If ActiveDocument.Endnotes.Count >= 5 Then
Selection.GoTo What:=wdGoToEndnote, _
Which:=wdGoToAbsolute, Count:=5
End If
Este exemplo move a seleção quatro linhas para baixo.This example moves the selection down four lines.
Selection.GoTo What:=wdGoToLine, Which:=wdGoToRelative, Count:=4
Este exemplo move a seleção duas linhas para trás.This example moves the selection back two pages.
Selection.GoTo What:=wdGoToPage, Which:=wdGoToPrevious, Count:=2
Confira tambémSee also
Objeto SelectionSelection Object
Suporte e comentáriosSupport and feedback
Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação?Have questions or feedback about Office VBA or this documentation? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.