Share via


Proprietà Workbook.VstoSmartTags

Ottiene l'oggetto Microsoft.Office.Tools.SmartTagCollection associato alla cartella di lavoro.

Spazio dei nomi:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Sintassi

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

Valore proprietà

Tipo: Microsoft.Office.Tools.SmartTagCollection
Oggetto Microsoft.Office.Tools.SmartTagCollection associato alla cartella di lavoro.

Esempi

Nell'esempio di codice riportato di seguito viene creato uno smart tag che imposta sul blu il colore del tipo di carattere di una cella al riconoscimento del termine "blue". Lo smart tag viene aggiunto alla cartella di lavoro utilizzando la proprietà VstoSmartTags.

Questa versione è valida per un componente aggiuntivo a livello di applicazione.

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Workbook Interfaccia

Spazio dei nomi Microsoft.Office.Tools.Excel

Altre risorse

Cenni preliminari sugli smart tag