Sdílet prostřednictvím


SmartTag-Konstruktor (2007 System)

Aktualisiert: November 2007

Initialisiert eine neue Instanz der SmartTag-Klasse.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.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. Wenn die Wörter "term" oder "recognize" in ein Dokument eingegeben werden, werden sie erkannt. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels, das für die Action-Klasse bereitgestellt wird.

Private WithEvents displayAddress As Microsoft.Office.Tools.Word.Action

Private Sub AddSmartTag()
    Dim smartTagDemo As New  _
        Microsoft.Office.Tools.Word.SmartTag( _
        "www.microsoft.com/Demo#DemoSmartTag", _
        "Demonstration Smart Tag")

    ' Specify the terms to recognize.
    smartTagDemo.Terms.Add("term")
    smartTagDemo.Terms.Add("recognize")

    ' Create the action.
    displayAddress = New Microsoft.Office.Tools.Word.Action("To be replaced")

    ' Add the action to the smart tag.
    smartTagDemo.Actions = New Microsoft.Office.Tools.Word.Action() { _
            displayAddress}

    ' Add the smart tag.
    Me.VstoSmartTags.Add(smartTagDemo)
End Sub
private Microsoft.Office.Tools.Word.Action displayAddress;

private void AddSmartTag()
{
    Microsoft.Office.Tools.Word.SmartTag smartTagDemo =
        new Microsoft.Office.Tools.Word.SmartTag(
        "www.microsoft.com/Demo#DemoSmartTag",
        "Demonstration Smart Tag");

    // Specify the terms to recognize.
    smartTagDemo.Terms.Add("term");
    smartTagDemo.Terms.Add("recognize");

    // Create the action.
    displayAddress = new Microsoft.Office.Tools.Word.Action("To be replaced");

    // Add the action to the smart tag.
    smartTagDemo.Actions = new Microsoft.Office.Tools.Word.Action[] { 
        displayAddress };

    // Add the smart tag.
    this.VstoSmartTags.Add(smartTagDemo);

    displayAddress.BeforeCaptionShow += new
        Microsoft.Office.Tools.Word.BeforeCaptionShowEventHandler(
        displayAddress_BeforeCaptionShow);

    displayAddress.Click += new
        Microsoft.Office.Tools.Word.ActionClickEventHandler(
        displayAddress_Click);
}

Berechtigungen

Siehe auch

Referenz

SmartTag-Klasse

SmartTag-Member

Microsoft.Office.Tools.Word-Namespace