SmartTagBase.Expressions 屬性 (2007 系統)

更新:2007 年 11 月

取得規則運算式的集合,智慧標籤會辨識這些規則運算式。

命名空間:  Microsoft.Office.Tools
組件:  Microsoft.Office.Tools.Common.v9.0 (在 Microsoft.Office.Tools.Common.v9.0.dll 中)

語法

Public ReadOnly Property Expressions As RegexCollection

Dim instance As SmartTagBase
Dim value As RegexCollection

value = instance.Expressions
public RegexCollection Expressions { get; }

屬性值

型別:Microsoft.Office.Tools.RegexCollection

取得 RegexCollection,包含智慧標籤會辨識的規則運算式。

備註

使用 Add 方法,將規則運算式加入至一組規則運算式中,智慧標籤會辨識這些規則運算式。

範例

下列程式碼範例會建立 Microsoft.Office.Tools.Excel.SmartTag,然後使用 Expressions 屬性,將規則運算式 "[I|i]ssue\s\d{5,6}" 加入至智慧標籤會辨識之規則運算式的集合。這個程式碼範例是 Microsoft.Office.Tools.Excel.Action 類別完整範例的一部分。

這是示範文件層級自訂的範例。

WithEvents displayAddress As Microsoft.Office.Tools.Excel.Action

Private Sub AddSmartTag()
    Dim smartTagDemo As New  _
        Microsoft.Office.Tools.Excel.SmartTag( _
        "www.microsoft.com/Demo#DemoSmartTag", _
        "Demonstration Smart Tag")

    ' Specify a term and an expression to recognize.
    smartTagDemo.Terms.Add("sale")
    smartTagDemo.Expressions.Add( _
        New System.Text.RegularExpressions.Regex( _
        "[I|i]ssue\s\d{5,6}"))

    ' Create the action.
    displayAddress = New Microsoft.Office.Tools.Excel.Action( _
        "To be replaced")

    ' Add the action to the smart tag.
    smartTagDemo.Actions = New Microsoft.Office.Tools.Excel.Action() { _
            displayAddress}

    ' Add the smart tag.
    Me.VstoSmartTags.Add(smartTagDemo)
End Sub
private Microsoft.Office.Tools.Excel.Action displayAddress;

private void AddSmartTag()
{
    Microsoft.Office.Tools.Excel.SmartTag smartTagDemo =
        new Microsoft.Office.Tools.Excel.SmartTag(
        "www.microsoft.com/Demo#DemoSmartTag",
        "Demonstration Smart Tag");

    // Specify a term and an expression to recognize.
    smartTagDemo.Terms.Add("sale");
    smartTagDemo.Expressions.Add(
        new System.Text.RegularExpressions.Regex(
        @"[I|i]ssue\s\d{5,6}"));

    // Create the action.
    displayAddress = new Microsoft.Office.Tools.Excel.Action(
        "To be replaced");

    // Add the action to the smart tag.
    smartTagDemo.Actions = new Microsoft.Office.Tools.Excel.Action[] { 
        displayAddress };

    // Add the smart tag.
    this.VstoSmartTags.Add(smartTagDemo);

    displayAddress.BeforeCaptionShow += new 
        Microsoft.Office.Tools.Excel.BeforeCaptionShowEventHandler(
        DisplayAddress_BeforeCaptionShow);

    displayAddress.Click += new 
        Microsoft.Office.Tools.Excel.ActionClickEventHandler(
        DisplayAddress_Click);
}

使用權限

請參閱

參考

SmartTagBase 類別

SmartTagBase 成員

Microsoft.Office.Tools 命名空間