更新 : 2007 年 11 月
SmartTag クラスの新しいインスタンスを初期化します。
名前空間 : Microsoft.Office.Tools.Excel
アセンブリ : Microsoft.Office.Tools.Excel.v9.0 (Microsoft.Office.Tools.Excel.v9.0.dll 内)
構文
'宣言
Public Sub New ( _
smartTagType As String, _
caption As String _
)
'使用
Dim smartTagType As String
Dim caption As String
Dim instance As New SmartTag(smartTagType, _
caption)
public SmartTag(
string smartTagType,
string caption
)
パラメータ
smartTagType
型 : System.Stringスマート タグ用の一意の識別子です。名前空間の URI とタグの型名とをシャープ記号で区切って構成されます。
caption
型 : System.Stringスマート タグ メニューに表示される、スマート タグの名前です。
例外
例外 | 条件 |
---|---|
ArgumentException | smartTagType または caption が nullnull 参照 (Visual Basic では Nothing) または空であるか、smartTagType が無効です。 |
解説
SmartTagType の例が http://smarttags.contoso.com#TagName にあります。整形式 SmartTagType に空白は含まれません。また、このタグの型名は、文字 (a ~ z および A ~ Z)、アンダースコア (_)、またはコロン (:) で始まります。
例
次のコード例では、SmartTag コンストラクタを呼び出すことによって SmartTag を作成し、Actions コレクションにアクションを追加します。次のコード例は、Action クラス用のより大きなコード例の一部です。
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);
}
アクセス許可
- 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。