Share via


Bookmark.GoTo(Object, Object, Object, Object) Méthode

Définition

Obtient un objet Range qui représente la position de début d'un élément dans le contrôle Bookmark.

public Microsoft.Office.Interop.Word.Range GoTo (ref object What, ref object Which, ref object Count, ref object Name);
abstract member 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

Paramètres

What
Object

Genre d'élément pour lequel le Range est récupéré. Ce peut être l’une des constantes WdGoToItem.

Which
Object

L'élément pour lequel le Range est récupéré peut être l'une des constantes WdGoToDirection.

Count
Object

Numéro de l'élément dans le document. La valeur par défaut est 1. Seules les valeurs positives sont valides. Pour spécifier un élément qui précède le Bookmark contrôle, utilisez wdGoToPrevious comme Which argument et spécifiez une Count valeur.

Name
Object

Si l’argument What est wdGoToBookmark, wdGoToComment, wdGoToFieldou wdGoToObject, cet argument spécifie un nom.

Retours

Objet Range.

Exemples

L’exemple de code suivant insère un Bookmark contrôle avec du texte mal orthographié dans le premier paragraphe, puis accède à la première erreur d’orthographe dans le signet et affiche sa position dans une zone de message.

Cet exemple concerne une personnalisation au niveau du document.

private void BookmarkGoTo()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
       this.Controls.AddBookmark(this.Paragraphs[1].Range,
       "bookmark1");
    bookmark1.Text = "This bookmark contains spellling erors.";

    object What = Word.WdGoToItem.wdGoToSpellingError;
    object Which = Word.WdGoToDirection.wdGoToFirst;
    
    Word.Range range1 = bookmark1.GoTo(ref What, ref Which, ref missing, 
        ref missing);

    MessageBox.Show("The first spelling error in bookmark1 is at position " 
        + range1.Start.ToString());
}
Private Sub BookmarkGoTo()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
    Bookmark1.Text = "This bookmark contains spellling erors."

    Dim Range1 As Word.Range = Bookmark1.GoTo( _
        What:=Word.WdGoToItem.wdGoToSpellingError, _
        Which:=Word.WdGoToDirection.wdGoToFirst)

    MessageBox.Show("The first spelling error in Bookmark1 " & _
        "is at position " & Range1.Start.ToString)

End Sub

Remarques

Lorsque vous utilisez la GoTo méthode avec la wdGoToGrammaticalErrorconstante , wdGoToProofreadingErrorou wdGoToSpellingError , le qui est retourné inclut tout Range texte d’erreur de grammaire ou texte d’erreur orthographique.

Paramètres facultatifs

Pour plus d’informations sur les paramètres facultatifs, consultez Paramètres facultatifs dans les solutions Office.

S’applique à