Aracılığıyla paylaş


Action Arabirim

Visual Studio Office geliştirme araçlarını kullanarak özelleştirilmiş bir Excel çalışma kitabındaki bir akıllı etiket eylemi temsil eder.

Ad alanı:  Microsoft.Office.Tools.Excel
Derleme:  Microsoft.Office.Tools.Excel (Microsoft.Office.Tools.Excel.dll içinde)

Sözdizimi

'Bildirim
<GuidAttribute("37e25b46-6941-4833-9b08-e692cf461982")> _
Public Interface Action _
    Inherits ActionBase
[GuidAttribute("37e25b46-6941-4833-9b08-e692cf461982")]
public interface Action : ActionBase

Action türü aşağıdaki üyeleri ortaya koyar.

Özellikler

  Ad Açıklama
Genel özellik Caption Alır veya akıllı etiket menüsünde görüntülenen eylemin adını ayarlar. (ActionBase kaynağından devralındı.)

Üst

Olaylar

  Ad Açıklama
Genel olay BeforeCaptionShow Kullanıcı akıllı etiket simgesini tıklattıktan sonra önce Akıllı etiket menüsünde görüntülenen oluşur.
Genel olay Click Akıllı etiket menüsünde eylem tıklatıldığında gerçekleşir.

Üst

Açıklamalar

Belirli bir türdeki akıllı etiket tanındığında akıllı etiket kısayol menüsünde kullanılabilir seçenekleri eylemlerdir. Eylem oluşturmak için Globals.Factory.CreateAction oluşturma yöntemi bir Action nesne. Daha fazla bilgi için bkz. Akıllı Etiketler Mimarisi.

Not

Bu arabirim Office için Visual Studio Araçları çalışma zamanı modülü tarafından uygulanır. Kodunuzda gerçekleştirilmesi amaçlanmamıştır. Daha fazla bilgi için bkz: Office için Visual Studio Araçları Çalışma Zamanına Genel Bakış.

Kullanım

Bu tür projelerde yalnızca Excel 2007 için kullanılmak üzere hazırlanmıştır. Akıllı etiketler Excel 2010 kaldırılmıştır. Daha fazla bilgi için bkz. Akıllı Etiketlere Genel Bakış.

Bu belgelerde, .NET Framework 4'ü hedefleyen projelerde kullanılan bu türün sürümü açıklanır. .NET Framework 3.5'i hedefleyen projelerde, bu türün üyeleri farklı olabilir ve bu tür için sağlanan kod örnekleri çalışmayabilir. .NET Framework 3.5'i hedefleyen projelerde bu tür hakkındaki belgeler için, Visual Studio 2008 belgelerinde aşağıdaki başvuru bölümüne bakın: https://go.microsoft.com/fwlink/?LinkId=160658.

Örnekler

Aşağıdaki kod örneği oluşturur bir SmartTag ile bir Action "Satış" terimi tanır ve normal ifade "[I|i] ssue\s\d {5,6}". Eylem anında eylem menü başlığını değiştirir ve tanınan metni adresini görüntüler. Örneği test etmek için "Satış" sözcüğünü yazın. bir hücre ve dize "sorunu 12345" başka bir hücre ve akıllı etiket eylem çalışın.

WithEvents displayAddress As Microsoft.Office.Tools.Excel.Action

Private Sub AddSmartTag()

    ' Create the smart tag for .NET Framework 4 projects.
    Dim smartTagDemo As Microsoft.Office.Tools.Excel.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.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 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.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 DisplayAddress_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()
{
    // Create the smart tag for .NET Framework 4 projects.
    Microsoft.Office.Tools.Excel.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.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 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.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);
}

Ayrıca bkz.

Başvuru

Microsoft.Office.Tools.Excel Ad Alanı

SmartTag

Diğer Kaynaklar

Akıllı Etiketler Mimarisi

Nasıl Yapılır: Excel Çalışma Kitaplarına Akıllı Etiketler Ekleme

Nasıl Yapılır: Excel and .NET Framework 3.5'te Özel Tanıyıcılarla Akıllı Etiketler Oluşturma