Share via


SmartTagCollection Interface

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

Namespace:  Microsoft.Office.Tools
Assemblies:   Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)
  Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)

Syntax

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

The SmartTagCollection type exposes the following members.

Properties

  Name Description
Public property Item 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.
.

Top

Methods

  Name Description
Public method Add 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.
.
Public method AddRange 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.
.
Public method BeginInit Infrastructure.
Public method Contains 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.
.
Public method CopyTo 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.
.
Public method Dispose Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.)
Public method EndInit Infrastructure.
Public method GetEnumerator Returns an enumerator that iterates through a collection. (Inherited from IEnumerable.)
Public method IndexOf 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.
.
Public method Insert 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.
.
Public method Remove 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.
.

Top

Remarks

When you create a smart tag, you add a SmartTagBase object to the Workbook.VstoSmartTags or 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 and the .NET Framework 4.5. 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: https://go.microsoft.com/fwlink/?LinkId=160658.

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 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.

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

See Also

Reference

Microsoft.Office.Tools Namespace