Bookmark.Find 属性

获取一个 Find 对象,该对象包含在一个 Bookmark 控件中进行查找操作的条件。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)

语法

声明
ReadOnly Property Find As Find
Find Find { get; }

属性值

类型:Microsoft.Office.Interop.Word.Find
一个 Find 对象,包含在一个 Bookmark 控件中进行查找操作的条件。

示例

下面的代码示例向第一个段落添加一个带有文本的 Bookmark 控件,然后在该书签中用单词 replacement 替换单词 sample。

此示例针对的是文档级自定义项。

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
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);
}

.NET Framework 安全性

请参见

参考

Bookmark 接口

Microsoft.Office.Tools.Word 命名空间