Share via


Workbook.VstoSmartTags Property

Gets the Microsoft.Office.Tools.SmartTagCollection associated with the workbook.

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

Syntax

'Declaration
ReadOnly Property VstoSmartTags As SmartTagCollection
    Get
SmartTagCollection VstoSmartTags { get; }

Property Value

Type: Microsoft.Office.Tools.SmartTagCollection
The Microsoft.Office.Tools.SmartTagCollection associated with the workbook.

Examples

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.

WithEvents ColorText As Microsoft.Office.Tools.Excel.Action

Private Sub AddSmartTag()
    Dim vstoWorkbook As Workbook = Globals.Factory.GetVstoObject(Me.Application.ActiveWorkbook)
    Dim ColorTag As SmartTag = Globals.Factory.CreateSmartTag( _
           "www.contoso.com/Demo#DemoSmartTag", "Demo Smart Tag")

    Dim ColorText As Microsoft.Office.Tools.Excel.Action =
        Globals.Factory.CreateAction("Color text blue")
    AddHandler ColorText.Click, AddressOf ColorText_Click

    ColorTag.Actions = _
        New Microsoft.Office.Tools.Excel.Action() {ColorText}
    ColorTag.Terms.Add("blue")
    vstoWorkbook.VstoSmartTags.Add(ColorTag)
End Sub

Private Sub ColorText_Click(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Excel.ActionEventArgs)
    e.Range.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue)
End Sub
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);
}

.NET Framework Security

See Also

Reference

Workbook Interface

Microsoft.Office.Tools.Excel Namespace

Other Resources

Smart Tags Overview