ApplicationFactory.CreateAction-Methode
Erstellt ein Action-Objekt, das eine Aktion für ein Smarttag darstellt. Dieser Typ oder Member ist nur für die Verwendung in Projekten für das Microsoft Office 2007-System vorgesehen. Smarttags sind in Office 2010 veraltet.
.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Syntax
'Declaration
Function CreateAction ( _
caption As String _
) As Action
Action CreateAction(
string caption
)
Parameter
- caption
Typ: System.String
Der Name der Aktion, der vom Smarttagmenü angezeigt wird.
Rückgabewert
Typ: Microsoft.Office.Tools.Excel.Action
Die neue Smarttagaktion.
Beispiele
Im folgenden Codebeispiel wird veranschaulicht, wie ein Smarttag und eine Aktion in einem Excel-Arbeitsmappenprojekt erstellt werden. Um dieses Codebeispiel verwenden zu können, müssen Sie den Code in der ThisAddIn-Klasse ausführen.
WithEvents displayAddress As Microsoft.Office.Tools.Excel.Action
Private Sub AddSmartTag()
Dim smartTagDemo As Microsoft.Office.Tools.Excel.SmartTag = _
Globals.Factory.CreateSmartTag(
"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}"))
displayAddress = Globals.Factory.CreateAction("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 =
Globals.Factory.CreateSmartTag(
"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}"));
displayAddress = Globals.Factory.CreateAction("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);
}
.NET Framework-Sicherheit
- Volle Vertrauenswürdigkeit für den unmittelbaren Aufrufer. Dieser Member kann von nur teilweise vertrauenswürdigem Code nicht verwendet werden. Weitere Informationen finden Sie unter Verwenden von Bibliotheken aus teilweise vertrauenswürdigem Code.