Bookmark.InRange(Range) Méthode

Définition

Détermine si le Range auquel la méthode est appliquée est contenu dans le contrôle Bookmark.

public bool InRange (Microsoft.Office.Interop.Word.Range Range);

Paramètres

Range
Range

Objet Range.

Retours

Boolean

true si le Range spécifié se trouve dans le contrôle Bookmark auquel la méthode est appliquée ; sinon, false.

Exemples

L’exemple de code suivant ajoute un Bookmark contrôle avec du texte au document, puis vérifie si le signet est dans la même plage que le paragraphe 1. Ce code affiche ensuite les résultats dans une boîte de message.

Cet exemple est destiné à une personnalisation au niveau du document.

private void BookmarkInRange()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text.";
    if (bookmark1.InRange(this.Paragraphs[1].Range))
    {
        MessageBox.Show("The bookmark is in the first paragraph.");
    }
    else
    {
        MessageBox.Show("The bookmark is not in the first paragraph.");
    }
}
Private Sub BookmarkInRange()

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

    If Bookmark1.InRange(Me.Paragraphs(1).Range) Then
        MessageBox.Show("The bookmark is in the first paragraph.")
    Else
        MessageBox.Show("The bookmark is not in the first paragraph.")
    End If

End Sub

Remarques

Cette méthode détermine si le Range est contenu dans le Bookmark contrôle en comparant les positions des caractères de début et de fin, ainsi que le type d’histoire.

S’applique à