SmartTag Constructor
Initializes a new instance of the SmartTag class.
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
)
Parameters
- smartTagType
Type: System.String
A unique identifier for the smart tag, composed of a namespace URI and a tag type name separated by a number sign (#).
- caption
Type: System.String
The name of the smart tag, which is displayed on the smart tag menu.
Exceptions
| Exception | Condition |
|---|---|
| ArgumentException | smartTagType or caption is either nulla null reference (Nothing in Visual Basic) or empty, or smartTagType is not valid. |
Remarks
An example of a SmartTagType is https://smarttags.contoso.com#TagName. A well-formed SmartTagType does not contain white space and its tag type name starts with a letter (a-z, A-Z), an underscore (_) or a colon (:).
Examples
The following code example creates a smart tag by calling the SmartTag constructor, and then adds an action to the Actions collection. When the words "term" or "recognize" are entered in a document, they are recognized. This code example is part of a larger example provided for the Action class.
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);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.