Export (0) Print
Expand All
Expand Minimize

Workbook.VstoSmartTags Property

Gets the Microsoft.Office.Tools.SmartTagCollection associated with the workbook. 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. .

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

SmartTagCollection VstoSmartTags { get; }

The following code example creates a smart tag that sets the font color of a cell to blue when the term "blue" is recognized. The example adds the smart tag to the workbook by using the VstoSmartTags property.

This version is for an application-level add-in.

private void AddSmartTag()
{
    Microsoft.Office.Tools.Excel.SmartTag colorTag =
        Globals.Factory.CreateSmartTag(
        "www.contoso.com/Demo#DemoSmartTag", "Demo Smart Tag");

    Microsoft.Office.Tools.Excel.Action colorText =
        Globals.Factory.CreateAction("Color text blue");
    colorText.Click +=
        new Microsoft.Office.Tools.Excel.ActionClickEventHandler(
        colorText_Click);

    Workbook vstoWorkbook = Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook);

    colorTag.Actions =
        new Microsoft.Office.Tools.Excel.Action[] {
            colorText };
    colorTag.Terms.Add("blue");
    vstoWorkbook.VstoSmartTags.Add(colorTag);
}

private void colorText_Click(object sender,
    Microsoft.Office.Tools.Excel.ActionEventArgs e)
{
    e.Range.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue);
}

Show:
© 2014 Microsoft