Udostępnij za pośrednictwem


Metoda ApplicationFactory.CreateSmartTag —

Tworzy SmartTag obiekt, który reprezentuje tagów inteligentnych w arkuszu.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.Excel
Zestaw:  Microsoft.Office.Tools.Excel (w Microsoft.Office.Tools.Excel.dll)

Składnia

'Deklaracja
Function CreateSmartTag ( _
    smartTagType As String, _
    caption As String, _
    extension As ISmartTagExtension _
) As SmartTag
SmartTag CreateSmartTag(
    string smartTagType,
    string caption,
    ISmartTagExtension extension
)

Parametry

  • smartTagType
    Typ: System.String
    Identyfikator unikatowy dla tagu inteligentnego, składa się z identyfikatora URI obszaru nazw i nazwę typu znacznika oddzielonych znakiem numeru (#).
  • caption
    Typ: System.String
    Nazwa tagu inteligentnego, który jest wyświetlany w menu tagu inteligentnego.

Wartość zwracana

Typ: Microsoft.Office.Tools.Excel.SmartTag
Nowy tag inteligentny.

Wyjątki

Wyjątek Warunek
ArgumentException

smartTagTypelub caption jest nullodwołanie o wartości null (Nothing w języku Visual Basic) lub jest pusty, lub smartTagType jest nieprawidłowa.

Uwagi

Przykładem prawidłowy ciąg dla smartTagType parametr jest http://smarttags.contoso.com#TagName.Poprawnie sformułowany tagów inteligentnych typu ciąg nie zawiera owiatło i zaczyna się od litery (a-z, A-Z), znaku podkreślenia (_) lub dwukropka (:).

Przykłady

Poniższy kod ilustruje tworzenie tagów inteligentnych i akcji w projekcie dodatek programu Excel.Aby wykorzystać ten przykład, należy uruchomić kod z ThisAddIn klasy.

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

ApplicationFactory Interfejs

Przestrzeń nazw Microsoft.Office.Tools.Excel