Action Interface

 

Represents a smart tag action 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)

[GuidAttribute("37e25b46-6941-4833-9b08-e692cf461982")]
public interface Action : ActionBase

NameDescription
System_CAPS_pubpropertyCaption

Gets or sets the name of the action, as displayed in the smart tag menu.

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.

.(Inherited from ActionBase.)

NameDescription
System_CAPS_pubeventBeforeCaptionShow

Occurs after the user clicks the smart tags icon, and before the smart tag menu is displayed.

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.

.

System_CAPS_pubeventClick

Occurs when the action in the smart tag menu is clicked.

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.

.

Actions are the choices available on the smart tag shortcut menu when a smart tag of a certain type is recognized. To create an action, use the Globals.Factory.CreateAction method to create an Action object..

System_CAPS_noteNote

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

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.

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

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 " +
            e.Text;
    }
}

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