共用方式為


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 命名空間