locked
How to handle ActiveX controls event through Interoperability RRS feed

  • Question

  •  

    I have a Word 2007 Document project created with VSTO 3.0 and VS 2008. My requirement is to add an ActiveX Button

     to the word document and handle the event for the added button.

     

    I've created the button in the Document with below code:

     

    private void createOLEControl()

    {

    object objbutton = "Forms.CommandButton.1";

    object objMissing = System.Type.Missing;

    Word.Shape Text;

     

    Text = this.Application.ActiveDocument.Shapes.AddOLEControl(ref objbutton, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing);

    Text.OLEFormat.Object.GetType().InvokeMember("Name", System.Reflection.BindingFlags.SetProperty, null, Text.OLEFormat.Object, new object[] { "Click" });

    }

     

    But I would like to know how to handle the click event for this CommandButton,

    It would be great if you could give me sample C# code to handle "Click" event.

    Tuesday, October 7, 2008 12:10 PM

Answers

  •   Hi d4rr3n123,

    This forum is to support Interoperability questions on the Open Protocols Specifications.

    I would suggest that you post your question to a more suitable forum like:



    Visual C# General

    RSS
    General discussion and questions regarding Visual C# -- including best practices on developing with C# in VS, documentation, setup, and samples.

    http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/threads/

    Thanks,
    SEBASTIAN CANEVARI - MSFT SEE Protocol Documentation Team
    • Marked as answer by Steve Smegner Friday, October 10, 2008 11:37 PM
    Wednesday, October 8, 2008 6:27 PM
    Moderator