次の方法で共有


SmartTagCollection インターフェイス

Visual Studio で Office 開発ツールを使用して作成された Word または Excel ソリューションのスマート タグのコレクションを表します。

名前空間:  Microsoft.Office.Tools
アセンブリ:  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 指定されたインデックスにあるスマート タグを取得します。

このページのトップへ

メソッド

  名前 説明
パブリック メソッド Add SmartTagCollection の最後にスマート タグを追加します。
パブリック メソッド AddRange SmartTagCollection の最後にスマート タグの配列を追加します。
パブリック メソッド BeginInit インフラストラクチャ。
パブリック メソッド Contains SmartTagCollection に指定のスマート タグが含まれているかどうかを確認します。
パブリック メソッド CopyTo SmartTagCollection 内のスマート タグを、スマート タグの 1 次元配列に、指定のインデックスからコピーします。
パブリック メソッド Dispose アンマネージ リソースの解放およびリセットに関連付けられているアプリケーション定義のタスクを実行します。 (IDisposable から継承されます。)
パブリック メソッド EndInit インフラストラクチャ。
パブリック メソッド GetEnumerator コレクションを反復処理する列挙子を返します。 (IEnumerable から継承されます。)
パブリック メソッド IndexOf SmartTagCollection 内の指定のスマート タグのインデックスを確認します。
パブリック メソッド Insert スマート タグを、SmartTagCollection 内の指定のインデックスの位置に挿入します。
パブリック メソッド Remove SmartTagCollection からスマート タグを削除します。

このページのトップへ

解説

スマート タグを作成するときには、SmartTagBase オブジェクトを Workbook.VstoSmartTags または Document.VstoSmartTags プロパティに追加します。 これらのプロパティは、SmartTagCollection 型に設定されています。

Office ソリューションでのスマート タグの詳細については、「スマート タグの概要」を参照してください。

注意

これは、Visual Studio Tools for Office ランタイムによって実装されたインターフェイスです。 コードに実装されるものではありません。 詳細については、「Visual Studio Tools for Office Runtime の概要」を参照してください。

使用方法

この型は、Excel 2007 および Word 2007 のプロジェクトでのみ使用されます。 スマート タグは Excel 2010 および Word 2010 では使用されていません。 詳細については、「スマート タグの概要」を参照してください。

ここでは、.NET Framework 4 を対象とする Office プロジェクトで使用される型のバージョンについて説明します。.NET Framework 3.5 を対象とするプロジェクトでは、この型のメンバーが異なること、およびこのコード例が動作しないことがあります。 .NET Framework 3.5 を対象とするプロジェクトの型の詳細については、Visual Studio 2008 ドキュメントの参照セクション https://go.microsoft.com/fwlink/?LinkId=160658 を参照してください。

Add メソッドを使用して、Workbook.VstoSmartTags プロパティで公開されているスマート タグのコレクションに Microsoft.Office.Tools.Excel.SmartTag を追加するコード例を次に示します。 このコード例は、Microsoft.Office.Tools.Excel.Action のトピックで取り上げているコード例の一部分です。

この例は、ドキュメント レベルのカスタマイズ用に作成されています。

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

Private Sub AddSmartTag()

    ' Create the smart tag for .NET Framework 4 projects.
    Dim smartTagDemo As Microsoft.Office.Tools.Excel.SmartTag = _
        Globals.Factory.CreateSmartTag(
        "www.microsoft.com/Demo#DemoSmartTag",
        "Demonstration Smart Tag")

    ' For .NET Framework 3.5 projects, use the following code to create the smart tag.
    ' 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 for .NET Framework 4 projects.
    displayAddress = Globals.Factory.CreateAction("To be replaced")

    ' For .NET Framework 3.5 projects, use the following code to 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()
{
    // Create the smart tag for .NET Framework 4 projects.
    Microsoft.Office.Tools.Excel.SmartTag smartTagDemo =
        Globals.Factory.CreateSmartTag(
            "www.microsoft.com/Demo#DemoSmartTag",
            "Demonstration Smart Tag");

    // For .NET Framework 3.5 projects, use the following code to create the smart tag.
    // 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 for .NET Framework 4 projects.
    displayAddress = Globals.Factory.CreateAction("To be replaced");

    // For .NET Framework 3.5 projects, use the following code to 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);
}

参照

参照

Microsoft.Office.Tools 名前空間

その他の技術情報

スマート タグの概要