Udostępnij za pośrednictwem


Metoda SmartTagCollection.Add —

Dodaje na końcu tagu inteligentnego SmartTagCollection.Ten typ lub element członkowski jest przeznaczony do stosowania wyłącznie w projektach dla systemu Microsoft Office 2007. W systemie Office 2010 tagi inteligentne nie są już używane.
.

Przestrzeń nazw:  Microsoft.Office.Tools
Zestaw:  Microsoft.Office.Tools.Common (w Microsoft.Office.Tools.Common.dll)

Składnia

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

Parametry

Wartość zwracana

Typ: System.Int32
Indeks nowych tagów inteligentnych w SmartTagCollection.

Przykłady

Następujący kod dodaje do zastosowań Add metoda, aby dodać Microsoft.Office.Tools.Excel.SmartTag do kolekcji tagów inteligentnych udostępniane przez Workbook.VstoSmartTags właściwość.Poniższy przykład kodu jest częścią większy przykład przewidziane Microsoft.Office.Tools.Excel.Action.

W tym przykładzie jest dla dostosowania poziomu dokumentu.

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

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

SmartTagCollection Interfejs

Przestrzeń nazw Microsoft.Office.Tools