Call an Event in Modules

  • Hello Friends


    I have Designed a Dashboard , i Have some Activex Command Buttons which change the color of some shapes according to their values , my problem is that i want to do this in the other way round , i want to assign macro to the shapes so that when the user clicks on the shapes , the command buttons be run .


    i tried inserting module then call commandButton1_click , but it didnt work .


    i ll be so thankful if u help me on this .

    Kind Regardssss

  • Re: How to Call an Event in Modules


    Standard code modules cannot host Events. Any event code for an ActiveX control must be in the code 'module' associated with the object raising the event (Worksheet/Workbook class, 'Standard' class, UserForm).


    Shapes or Form Controls are something different. With these you define a Macro to run when the object is clicked (Right click the shape/Assign Macro). This macro must be a public Sub in a standard code module.


    It might be useful if you uploaded a copy of your workbook if you cannot work it from that.


    [sw]*[/sw]

  • Re: Call an Event in Modules


    ActiveX control events are private by default, and can only be accessed through the code name of the sheet that contains the buttons. For example:


    Code
    Run "Sheet2.commandbutton1_click"


    It sounds to me as though your actual processing code should be in a normal module and then called by both your shapes and your command buttons.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!