Action 클래스(2007 시스템)

업데이트: 2007년 11월

Microsoft Office Excel 통합 문서에서 Visual Studio Tools for Office 스마트 태그 작업을 나타냅니다.

네임스페이스:  Microsoft.Office.Tools.Excel
어셈블리:  Microsoft.Office.Tools.Excel.v9.0(Microsoft.Office.Tools.Excel.v9.0.dll)

구문

<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public Class Action _
    Inherits ActionBase

Dim instance As Action
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class Action : ActionBase

설명

작업은 특정 형식의 스마트 태그가 인식되었을 때 스마트 태그 바로 가기 메뉴에서 사용할 수 있는 선택 항목입니다. 예를 들어, 사람 이름 형식의 문자열에 대해서는 "연락처 폴더에 이름 추가"가 가능한 작업이 될 수 있습니다. Visual Studio Tools for Office의 스마트 태그에 대한 자세한 내용은 스마트 태그 아키텍처를 참조하십시오.

예제

다음 코드 예제에서는 "sale"이라는 용어와 정규식 "[I|i]ssue\s\d{5,6}"을 인식하는 Action으로 SmartTag를 만듭니다. 이 작업은 런타임에 작업의 메뉴 캡션을 수정하고 인식된 텍스트의 주소를 표시합니다. 예제를 테스트하려면 한 셀에 "sale"이라는 단어를 입력하고 다른 셀에 "issue 12345"라는 문자열을 입력한 다음 스마트 태그 작업을 시도해 보십시오.

이 예제는 문서 수준 사용자 지정을 위한 것입니다.

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 Sub OpenMessageBox_BeforeCaptionShow(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Excel.ActionEventArgs) _
    Handles DisplayAddress.BeforeCaptionShow

    Dim clickedAction As Microsoft.Office.Tools.Excel.Action = _
        TryCast(sender, Microsoft.Office.Tools.Excel.Action)

    If clickedAction IsNot Nothing Then
        clickedAction.Caption = "Display the address of " & e.Text
    End If
End Sub

Private Sub DisplayAddress_Click(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Excel.ActionEventArgs) _
    Handles DisplayAddress.Click

    Dim smartTagAddress As String = e.Range.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
    MsgBox("The recognized text '" & e.Text & _
            "' is at range " & smartTagAddress)
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);
}

void DisplayAddress_BeforeCaptionShow(object sender, 
    Microsoft.Office.Tools.Excel.ActionEventArgs e)
{
    Microsoft.Office.Tools.Excel.Action clickedAction =
        sender as Microsoft.Office.Tools.Excel.Action;

    if (clickedAction != null)
    {
        clickedAction.Caption = "Display the address of " +
            e.Text;
    }
}

void DisplayAddress_Click(object sender, 
    Microsoft.Office.Tools.Excel.ActionEventArgs e)
{
    string smartTagAddress = e.Range.get_Address(missing,
        missing, Excel.XlReferenceStyle.xlA1, missing, missing);
    System.Windows.Forms.MessageBox.Show("The recognized text '" + e.Text +
        "' is at range " + smartTagAddress);
}

상속 계층 구조

System.Object
  Microsoft.Office.Tools.ActionBase
    Microsoft.Office.Tools.Excel.Action

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목

참조

Action 멤버

Microsoft.Office.Tools.Excel 네임스페이스

SmartTag

기타 리소스

스마트 태그 아키텍처

방법: Excel 통합 문서에 스마트 태그 추가

방법: Excel에서 사용자 지정 인식자로 스마트 태그 만들기