SmartTagCollection 介面

表示使用 Visual Studio 的 Office 開發工具建立之 Word 或 Excel 方案中的智慧標籤集合。

命名空間:  Microsoft.Office.Tools
組件:   Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)
  Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)
  Microsoft.Office.Tools.Common (在 Microsoft.Office.Tools.Common.dll 中)

語法

'宣告
<GuidAttribute("30a90086-8c89-4e19-8299-47765d808408")> _
Public Interface SmartTagCollection _
    Inherits IEnumerable, IDisposable
[GuidAttribute("30a90086-8c89-4e19-8299-47765d808408")]
public interface SmartTagCollection : IEnumerable, 
    IDisposable

SmartTagCollection 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 Item 取得位於指定索引上的智慧標籤。 這個類型或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
.

回頁首

方法

  名稱 說明
公用方法 Add 將智慧標籤加入至 SmartTagCollection 的結尾。 這個類型或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
.
公用方法 AddRange 將智慧標籤陣列加入至 SmartTagCollection 這個類型或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
的結尾。
公用方法 BeginInit 基礎架構。
公用方法 Contains 判斷 SmartTagCollection 是否包含特定的智慧標籤。 這個類型或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
.
公用方法 CopyTo 將 SmartTagCollection 中的智慧標籤複製到一維智慧標籤陣列,從指定的索引開始複製。 這個類型或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
.
公用方法 Dispose 執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。 (繼承自 IDisposable)。
公用方法 EndInit 基礎架構。
公用方法 GetEnumerator 傳回會逐一查看集合的列舉程式。 (繼承自 IEnumerable)。
公用方法 IndexOf 判斷所指定之智慧標籤在這個 SmartTagCollection 中的索引。 這個類型或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
.
公用方法 Insert 將智慧標籤插入至位於指定索引上的 SmartTagCollection。 這個類型或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
.
公用方法 Remove 從 SmartTagCollection 中移除智慧標籤。 這個類型或成員僅適用於 2007 Microsoft Office system 專案。智慧標籤在 Office 2010 中已被取代。
.

回頁首

備註

當您建立智慧標籤時,您會將 SmartTagBase 物件加入至 Workbook.VstoSmartTagsDocument.VstoSmartTags 屬性中。 這些屬性具有 SmartTagCollection 型別。

注意事項注意事項

這個介面是由 Visual Studio Tools for Office Runtime 實作,並不能實作於您的程式碼中。如需詳細資訊,請參閱 Visual Studio Tools for Office Runtime 概觀

使用方式

這個型別僅適用於 Excel 2007 和 Word 2007 專案。 Excel 2010 和 Word 2010 中已取代智慧標籤。

本文件說明此類型用於以 .NET Framework 4 和 .NET Framework 4.5 為目標之 Office 專案的版本。在以 .NET Framework 3.5 為目標的專案中,此類型可能會有不同的成員,而為此類型提供的程式碼範例可能無法運作。如需此類型在以 .NET Framework 3.5 為目標之專案中的相關文件,請參閱下列 Visual Studio 2008 文件中的參考章節:https://go.microsoft.com/fwlink/?LinkId=160658

範例

下列程式碼會使用 Add 方法,將 Microsoft.Office.Tools.Excel.SmartTag 加入至 Workbook.VstoSmartTags 屬性所公開 (Expose) 之智慧標籤的集合。 這個程式碼範例是 Microsoft.Office.Tools.Excel.Action 的完整範例的一部分。

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

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

Private Sub AddSmartTag()

    Dim smartTagDemo As Microsoft.Office.Tools.Excel.SmartTag = _
        Globals.Factory.CreateSmartTag(
        "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}"))

    displayAddress = Globals.Factory.CreateAction("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 =
        Globals.Factory.CreateSmartTag(
            "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}"));

    displayAddress = Globals.Factory.CreateAction("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);
}

請參閱

參考

Microsoft.Office.Tools 命名空間