SmartTag Constructor (2003 System)
Initializes a new instance of the SmartTag class.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.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 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 SmartTag by calling the SmartTag constructor, and then adds an action to the Actions collection. This code example is part of a larger example provided for the Action class.
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 to the workbook.
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 to the workbook.
this.VstoSmartTags.Add(SmartTagDemo);
DisplayAddress.BeforeCaptionShow += new
Microsoft.Office.Tools.Excel.BeforeCaptionShowEventHandler(
DisplayAddress_BeforeCaptionShow);
DisplayAddress.Click += new
Microsoft.Office.Tools.Excel.ActionClickEventHandler(
DisplayAddress_Click);
}
Permissions
- 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.