다음을 통해 공유


SmartTag 인터페이스

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

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

구문

‘선언
<GuidAttribute("2b90a8e2-4e6c-4c27-bd35-a6ba7b344223")> _
Public Interface SmartTag _
    Inherits SmartTagBase
[GuidAttribute("2b90a8e2-4e6c-4c27-bd35-a6ba7b344223")]
public interface SmartTag : SmartTagBase

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

속성

  이름 설명
Public 속성 Actions 스마트 태그에 의해 노출된 작업 배열을 가져오거나 설정합니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
. (SmartTagBase에서 상속됨)
Public 속성 Caption 스마트 태그의 이름을 가져옵니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
. (SmartTagBase에서 상속됨)
Public 속성 DefaultExtension 이 SmartTag 개체의 기본 확장을 가져옵니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
.
Public 속성 Expressions 스마트 태그가 인식할 정규식의 컬렉션을 가져옵니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
. (SmartTagBase에서 상속됨)
Public 속성 Extension 이 SmartTag 개체의 사용자 지정 확장을 가져옵니다.
Public 속성 SmartTagType 스마트 태그의 고유 식별자 역할을 하는 네임스페이스를 가져옵니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
. (SmartTagBase에서 상속됨)
Public 속성 Terms 스마트 태그가 인식할 문자열 리터럴의 컬렉션을 가져옵니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
. (SmartTagBase에서 상속됨)

위쪽

메서드

  이름 설명
Public 메서드 Remove 스마트 태그에서 정규식 인식자를 제거합니다. 이 형식 또는 멤버는 2007 Microsoft Office system용 프로젝트에서만 사용할 수 있습니다. Office 2010에서 스마트 태그는 더 이상 사용되지 않습니다.
. (SmartTagBase에서 상속됨)

위쪽

설명

스마트 태그를 만들려면 Globals.Factory.CreateSmartTag 메서드를 사용하여 SmartTag 개체를 만듭니다.

[!참고]

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

용도

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

예제

다음 코드 예제에서는 스마트 태그를 만드는 방법을 보여 줍니다.스마트 태그 작업은 런타임에 작업의 메뉴 캡션을 수정하고 인식된 텍스트의 위치를 표시합니다.

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