共用方式為


SmartTagBase.Terms 屬性 (2007 系統)

更新:2007 年 11 月

取得字串常值 (String Literal) 的集合,智慧標籤會辨識這些字串常值。

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

語法

Public ReadOnly Property Terms As StringCollection

Dim instance As SmartTagBase
Dim value As StringCollection

value = instance.Terms
public StringCollection Terms { get; }

屬性值

型別:System.Collections.Specialized.StringCollection

取得 StringCollection,包含智慧標籤會辨識的字串常值。

備註

使用 Add 方法,將字串常值加入至一組詞彙,智慧標籤會辨識這些詞彙。

範例

下列程式碼範例會建立 Microsoft.Office.Tools.Excel.SmartTag,然後使用 Terms 屬性,將單字 "sale" 加入至智慧標籤會辨識之詞彙的集合。這個程式碼範例是 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 命名空間