Action 인터페이스

Visual Studio의 Office 개발 도구를 사용하여 사용자 지정한 Word 문서의 스마트 태그 작업을 나타냅니다.

네임스페이스:  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

Action 형식에서는 다음과 같은 멤버를 노출합니다.

속성

  이름 설명
Public 속성 Caption 스마트 태그 메뉴에 표시되는 작업 이름을 가져오거나 설정합니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
. (ActionBase에서 상속됨)

위쪽

이벤트

  이름 설명
Public 이벤트 BeforeCaptionShow 사용자가 스마트 태그 아이콘을 클릭한 후 스마트 태그 메뉴가 표시되기 전에 발생합니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
.
Public 이벤트 Click 스마트 태그 메뉴에서 작업을 클릭할 경우 발생합니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
.

위쪽

설명

작업은 특정 형식의 스마트 태그가 인식되었을 때 스마트 태그 바로 가기 메뉴에서 사용할 수 있는 선택 항목입니다.작업을 만들려면 Globals.Factory.CreateAction 메서드를 사용하여 Action 개체를 만듭니다.

[!참고]

이 인터페이스는 Visual Studio Tools for Office Runtime에 의해 구현되며 코드에서 직접 구현할 수는 없습니다. 자세한 내용은 Visual Studio Tools for Office 런타임 개요를 참조하십시오.

용도

이 형식은 Word 2007용 프로젝트에서만 사용할 수 있습니다.Word 2010에서 스마트 태그를 사용 되지 않습니다.

이 설명서에서는 .NET Framework 4 및 .NET Framework 4.5를 대상으로 하는 Office 프로젝트에서 사용되는 이 형식의 버전에 대해 설명합니다. .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 네임스페이스

SmartTag

기타 리소스

Walkthrough: Creating a Smart Tag that Converts Temperatures from Fahrenheit to Celsius