Action الواجهة
يمثل ذكى علامة الإجراء في مستند الكلمة التي تم تخصيصها باستخدام أدوات تطوير المكتب في Visual Studio.
مساحة الاسم: Microsoft.Office.Tools.Word
التجميع: Microsoft.Office.Tools.Word (في Microsoft.Office.Tools.Word.dll)
بناء الجملة
'إقرار
<GuidAttribute("1886a0c6-4e1a-4b8f-8304-5143462fe2b6")> _
Public Interface Action _
Inherits ActionBase
[GuidAttribute("1886a0c6-4e1a-4b8f-8304-5143462fe2b6")]
public interface Action : ActionBase
ملاحظات
تكون الاجراءات الخيارات متوفر في قائمة المختصرة العلامات ذكى عند علامة ذكية من نوع معين هو التعرف عليها. إلى إنشاء إجراء ما، استخدم Globals.Factory.CreateActionأسلوب إلى إنشاء Actionالكائن. لمزيد من المعلومات، راجع هندسة العلامات الذكية.
ملاحظة
يتم تطبيق هذه الواجهة بواسطة Visual Studio Tools لوقت تشغيل Office. ولم يتم تصميمها لتطبيقها في التعليمة البرمجية الخاصة بك. لمزيد من المعلومات، راجع أدوات Visual Studio نظرة عامة وقت تشغيل Office.
الاستخدام
Th هو نوع هو مخصصة للاستخدام فقط في مشاريع لبرنامج الكلمة 2007. يتم مهمل علامات ذكى في الكلمة 2010. لمزيد من المعلومات، راجع نظرة عامة حول العلامات الذكية.
توضح هذه الوثائق الإصدار الخاص بهذا النوع المستخدم في مشاريع Office والذي يستهدف .NET Framework 4. وفي المشاريع التي تستهدف .NET Framework 3.5، قد يكون لدى هذا النوع أعضاء مختلفون وقد لا تعمل نماذج التعليمات البرمجية الخاصة بهذا النوع. للحصول على وثائق حول هذا النوع في المشاريع التي تستهدف .NET Framework 3.5، اطلع على جزء المرجع التالي في وثائق Visual Studio 2008: https://go.microsoft.com/fwlink/?LinkId=160658.
أمثلة
يوضح مثال التعليمة البرمجية التالية كيف إلى إنشاء علامة ذكية إجراءاً. إجراء علامة ذكى تعديل قائمة التسمية التوضيحية للإجراء في وقت التشغيل ويقوم بعرض الموقع للنص الذي تم التعرف عليه.
Private WithEvents displayAddress As Microsoft.Office.Tools.Word.Action
Private Sub AddSmartTag()
' Create the smart tag for .NET Framework 4 projects.
Dim smartTagDemo As Microsoft.Office.Tools.Word.SmartTag = Globals.Factory.CreateSmartTag(
"www.microsoft.com/Demo#DemoSmartTag",
"Demonstration Smart Tag")
' For .NET Framework 3.5 projects, use the following code to create the smart tag.
' 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 for .NET Framework 4 projects.
displayAddress = Globals.Factory.CreateAction("To be replaced")
' For .NET Framework 3.5 projects, use the following code to 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 Sub DisplayAddress_BeforeCaptionShow(ByVal sender As Object, _
ByVal e As Microsoft.Office.Tools.Word.ActionEventArgs) _
Handles displayAddress.BeforeCaptionShow
Dim clickedAction As Microsoft.Office.Tools.Word.Action = _
TryCast(sender, Microsoft.Office.Tools.Word.Action)
If clickedAction IsNot Nothing Then
clickedAction.Caption = "Display the location of " & e.Text
End If
End Sub
Private Sub DisplayAddress_Click(ByVal sender As Object, _
ByVal e As Microsoft.Office.Tools.Word.ActionEventArgs) _
Handles displayAddress.Click
Dim termStart As Integer = e.Range.Start
Dim termEnd As Integer = e.Range.End
MsgBox("The recognized text '" & e.Text & _
"' begins at position " & termStart & _
" and ends at position " & termEnd)
End Sub
private Microsoft.Office.Tools.Word.Action displayAddress;
private void AddSmartTag()
{
// Create the smart tag for .NET Framework 4 projects.
Microsoft.Office.Tools.Word.SmartTag smartTagDemo =
Globals.Factory.CreateSmartTag(
"www.microsoft.com/Demo#DemoSmartTag",
"Demonstration Smart Tag");
// For .NET Framework 3.5 projects, use the following code to create the smart tag.
// 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 for .NET Framework 4 projects.
displayAddress = Globals.Factory.CreateAction("To be replaced");
// For .NET Framework 3.5 projects, use the following code to 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);
}
void displayAddress_BeforeCaptionShow(object sender,
Microsoft.Office.Tools.Word.ActionEventArgs e)
{
Microsoft.Office.Tools.Word.Action clickedAction =
sender as Microsoft.Office.Tools.Word.Action;
if (clickedAction != null)
{
clickedAction.Caption = "Display the location of " +
e.Text;
}
}
void displayAddress_Click(object sender,
Microsoft.Office.Tools.Word.ActionEventArgs e)
{
int termStart = e.Range.Start;
int termEnd = e.Range.End;
System.Windows.Forms.MessageBox.Show("The recognized text '" + e.Text +
"' begins at position " + termStart.ToString() +
" and ends at position " + termEnd.ToString());
}
راجع أيضًَا
المرجع
Microsoft.Office.Tools.Word مساحة الاسم
موارد أخرى
كيفية: إضافة علامات ذكية إلى مستندات Word
كيفية: إنشاء علامات ذكية مع أدوات التعرف المخصصة في Word
الإرشادات التفصيلية: إنشاء علامة ذكية عن طريق استخدام تخصيص مستوى المستند