Sdílet prostřednictvím


SmartTag-Konstruktor (2007 System)

Aktualisiert: November 2007

Initialisiert eine neue Instanz der SmartTag-Klasse.

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

Syntax

'Declaration
Public Sub New ( _
    smartTagType As String, _
    caption As String _
)
'Usage
Dim smartTagType As String
Dim caption As String

Dim instance As New SmartTag(smartTagType, _
    caption)
public SmartTag(
    string smartTagType,
    string caption
)

Parameter

  • smartTagType
    Typ: System.String

    Eindeutiger Bezeichner für das Smarttag, der aus einem Namespace-URI und einem Tagtypnamen besteht, die durch ein Nummernzeichen (#) getrennt sind.

  • caption
    Typ: System.String

    Der Name des Smarttags, der im Smarttagmenü angezeigt wird.

Ausnahmen

Ausnahme Bedingung
ArgumentException

smartTagType oder caption ist nullNULL-Verweis (Nothing in Visual Basic) oder leer, oder smartTagType ist nicht gültig.

Hinweise

Ein Beispiel für SmartTagType ist http://smarttags.contoso.com#TagName. Ein wohlgeformter SmartTagType enthält keine Leerzeichen, und der zugehörige Tagtypname beginnt mit einem Buchstaben (a-z, A-Z), einem Unterstrich (_) oder einem Doppelpunkt (:).

Beispiele

Im folgenden Codebeispiel wird ein SmartTag durch Aufrufen des SmartTag-Konstruktors erstellt, und dann wird der Actions-Auflistung eine Aktion hinzugefügt. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels, das für die Action-Klasse bereitgestellt wird.

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

Private Sub AddSmartTag()
    Dim smartTagDemo As New  _
        Microsoft.Office.Tools.Excel.SmartTag( _
        "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}"))

    ' Create the action.
    displayAddress = New Microsoft.Office.Tools.Excel.Action( _
        "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 =
        new Microsoft.Office.Tools.Excel.SmartTag(
        "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}"));

    // Create the action.
    displayAddress = new Microsoft.Office.Tools.Excel.Action(
        "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);
}

Berechtigungen

Siehe auch

Referenz

SmartTag-Klasse

SmartTag-Member

Microsoft.Office.Tools.Excel-Namespace