SmartTag Interface

Represents a smart tag in an Excel workbook that is customized by using the Office development tools in Visual Studio.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

public interface SmartTag : SmartTagBase

The SmartTag type exposes the following members.

Public propertyActionsGets or sets an array of actions that are exposed by the smart tag. (Inherited from SmartTagBase.)
Public propertyCaptionGets the name of the smart tag. (Inherited from SmartTagBase.)
Public propertyDefaultExtensionGets the default extension for this SmartTag object.
Public propertyExpressionsGets the collection of regular expressions that the smart tag will recognize. (Inherited from SmartTagBase.)
Public propertyExtensionGets a custom extension for this SmartTag object.
Public propertySmartTagTypeGets a namespace that acts as a unique identifier for the smart tag. (Inherited from SmartTagBase.)
Public propertyTermsGets the collection of string literals that the smart tag will recognize. (Inherited from SmartTagBase.)

Public methodRemoveRemoves a regular expression recognizer from the smart tag. (Inherited from SmartTagBase.)

To create smart tag, use the Globals.Factory.CreateSmartTag method to create a SmartTag object. For information, see Smart Tags Architecture.


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.


This type is intended to be used only in projects for Excel 2007. Smart tags are deprecated in Excel 2010. For more information, see Smart Tags Overview.

This documentation describes the version of this type that is used in Office projects that target the .NET Framework 4. 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:

The following code example creates a SmartTag with an Action that recognizes the term "sale" and the regular expression "[I|i]ssue\s\d{5,6}". The action modifies the menu caption of the action at run time and displays the address of the text that was recognized. To test the example, type the word "sale" in one cell and the string "issue 12345" in another cell, and then try the smart tag action.

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 =
            "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(
        //     "",
        //     "Demonstration Smart Tag");

    // Specify a term and an expression to recognize.
        new System.Text.RegularExpressions.Regex(

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

    displayAddress.BeforeCaptionShow += new 

    displayAddress.Click += new 

void DisplayAddress_BeforeCaptionShow(object sender, 
    Microsoft.Office.Tools.Excel.ActionEventArgs e)
    Microsoft.Office.Tools.Excel.Action clickedAction =
        sender as Microsoft.Office.Tools.Excel.Action;

    if (clickedAction != null)
        clickedAction.Caption = "Display the address of " +

void DisplayAddress_Click(object sender, 
    Microsoft.Office.Tools.Excel.ActionEventArgs e)
    string smartTagAddress = e.Range.get_Address(missing,
        missing, Excel.XlReferenceStyle.xlA1, missing, missing);
    System.Windows.Forms.MessageBox.Show("The recognized text '" + e.Text +
        "' is at range " + smartTagAddress);

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft