Condividi tramite


Metodo SmartTagCollection.Add

Aggiunge uno smart tag alla fine dell'oggetto SmartTagCollection. Questo tipo o membro deve essere utilizzato solo nei progetti per Microsoft Office System 2007. Gli smart tag sono deprecati in Office 2010.
.

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

Sintassi

'Dichiarazione
Function Add ( _
    value As SmartTagBase _
) As Integer
int Add(
    SmartTagBase value
)

Parametri

Valore restituito

Tipo: System.Int32
Indice del nuovo smart tag nell'oggetto SmartTagCollection.

Esempi

Nell'esempio di codice riportato di seguito viene utilizzato il metodo Add per aggiungere un oggetto Microsoft.Office.Tools.Excel.SmartTag alla raccolta di smart tag esposta dalla proprietà Workbook.VstoSmartTags. Questo esempio di codice fa parte di un esempio più esaustivo fornito per Microsoft.Office.Tools.Excel.Action.

Questo esempio è valido per una personalizzazione a livello di documento.

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

Private Sub AddSmartTag()

    Dim smartTagDemo As Microsoft.Office.Tools.Excel.SmartTag = _
        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.
    Me.VstoSmartTags.Add(smartTagDemo)
End Sub
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);
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

SmartTagCollection Interfaccia

Spazio dei nomi Microsoft.Office.Tools