次の方法で共有


SmartTagCollection Interface

Definition

Represents a collection of smart tags in a Word or Excel solution created by using the Office development tools in Visual Studio.

public interface class SmartTagCollection : IDisposable, System::Collections::IEnumerable
[System.Runtime.InteropServices.Guid("30a90086-8c89-4e19-8299-47765d808408")]
public interface SmartTagCollection : IDisposable, System.Collections.IEnumerable
[<System.Runtime.InteropServices.Guid("30a90086-8c89-4e19-8299-47765d808408")>]
type SmartTagCollection = interface
    interface IEnumerable
    interface IDisposable
Public Interface SmartTagCollection
Implements IDisposable, IEnumerable
Attributes
Implements

Examples

The following code uses the Add method to add a Microsoft.Office.Tools.Excel.SmartTag to the collection of smart tags exposed by the Microsoft.Office.Tools.Excel.Workbook.VstoSmartTags property. This code example is part of a larger example provided for Microsoft.Office.Tools.Excel.Action.

This example is for a document-level customization.

    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);
    }
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

Remarks

When you create a smart tag, you add a SmartTagBase object to the Microsoft.Office.Tools.Excel.Workbook.VstoSmartTags or Microsoft.Office.Tools.Word.Document.VstoSmartTags properties. These properties have the type SmartTagCollection.

Note

This interface is implemented by the Visual Studio Tools for Office runtime. It is not intended to be implemented in your code. For more information, see Visual Studio Tools for Office Runtime Overview.

Usage

This type is intended to be used only in projects for Excel 2007 and Word 2007. Smart tags are deprecated in Excel 2010 and Word 2010.

This documentation describes the version of this type that is used in Office projects that target the .NET Framework 4 or later. In projects that target the .NET Framework 3.5, this type might have different members and the code examples provided for this type might not work. For documentation about this type in projects that target the .NET Framework 3.5, see the following reference section in the Visual Studio 2008 documentation: http://go.microsoft.com/fwlink/?LinkId=160658.

Properties

Item[Int32]

Gets the smart tag at the specified index. This type or member is intended to be used only in projects for the 2007 Microsoft Office system. Smart tags are deprecated in Office 2010..

Methods

Add(SmartTagBase)

Adds a smart tag to the end of the SmartTagCollection. This type or member is intended to be used only in projects for the 2007 Microsoft Office system. Smart tags are deprecated in Office 2010..

AddRange(SmartTagBase[])

Adds an array of smart tags to the end of the SmartTagCollectionThis type or member is intended to be used only in projects for the 2007 Microsoft Office system. Smart tags are deprecated in Office 2010..

Contains(SmartTagBase)

Determines whether the SmartTagCollection contains a specific smart tag. This type or member is intended to be used only in projects for the 2007 Microsoft Office system. Smart tags are deprecated in Office 2010..

CopyTo(SmartTagBase[], Int32)

Copies the smart tags in the SmartTagCollection to a one-dimensional array of smart tags, starting at a specified index. This type or member is intended to be used only in projects for the 2007 Microsoft Office system. Smart tags are deprecated in Office 2010..

IndexOf(SmartTagBase)

Determines the index of a specified smart tag in the SmartTagCollection. This type or member is intended to be used only in projects for the 2007 Microsoft Office system. Smart tags are deprecated in Office 2010..

Insert(Int32, SmartTagBase)

Inserts a smart tag into the SmartTagCollection at the specified index. This type or member is intended to be used only in projects for the 2007 Microsoft Office system. Smart tags are deprecated in Office 2010..

Remove(SmartTagBase)

Removes a smart tag from the SmartTagCollection. This type or member is intended to be used only in projects for the 2007 Microsoft Office system. Smart tags are deprecated in Office 2010..

Applies to