共用方式為


SmartTagBase.Actions 屬性 (2007 系統)

更新:2007 年 11 月

取得或設定智慧標籤所公開 (Expose) 的動作陣列。

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

語法

Public Property Actions As ActionBase()

Dim instance As SmartTagBase
Dim value As ActionBase()

value = instance.Actions

instance.Actions = value
public ActionBase[] Actions { get; set; }

屬性值

型別:array<Microsoft.Office.Tools.ActionBase[]

動作的陣列,由智慧標籤所公開。

例外狀況

例外狀況 條件
InvalidOperationException

這個屬性是在智慧標籤加入至 SmartTagCollection 之後設定。

備註

陣列的大小必須是預先決定的,這是因為以動態方式將動作加入至智慧標籤,會導致文件中所有的智慧標籤重新載入。

範例

下列程式碼範例會建立 Microsoft.Office.Tools.Excel.SmartTag,然後將動作加入至 Actions 屬性。這個程式碼範例是 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 命名空間