Share via


Bookmark.Find Property

Definition

Gets a Find object that contains the criteria for a find operation within a Bookmark control.

public:
 property Microsoft::Office::Interop::Word::Find ^ Find { Microsoft::Office::Interop::Word::Find ^ get(); };
public Microsoft.Office.Interop.Word.Find Find { get; }
member this.Find : Microsoft.Office.Interop.Word.Find
Public ReadOnly Property Find As Find

Property Value

A Find object that contains the criteria for a find operation within a Bookmark control.

Examples

The following code example adds a Bookmark control with text to the first paragraph, then replaces the word sample with the word replacement within the bookmark.

This example is for a document-level customization.

private void BookmarkFind()
{
    object FindText = "sample";
    object ReplaceWith = "replacement";
    object Replace = Word.WdReplace.wdReplaceAll;
    object Forward = true;
    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.";
    MessageBox.Show("Bookmark text before using Find method: " + bookmark1.Text);
        
    bookmark1.Find.Execute(ref FindText, ref missing, ref missing,
        ref missing, ref missing, ref Forward, ref missing, ref
        missing,ref missing,ref ReplaceWith, ref Replace, ref missing, 
        ref missing, ref missing, ref missing);
    
    MessageBox.Show("Bookmark text after using Find method: " + bookmark1.Text);
}
Private Sub BookmarkFind()
    
    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."

    MessageBox.Show("Bookmark text before using Find method: " & Bookmark1.Text)

    Bookmark1.Find.Execute(FindText:="sample", ReplaceWith:="replacement", _
        Replace:=Word.WdReplace.wdReplaceAll, Forward:=True)

    MessageBox.Show("Bookmark text after using Find method: " & Bookmark1.Text)

End Sub

Applies to