excel vba - Calling an ActiveX control Button from a macro -


i have written vba-excel code excecuted press of activex control button placed on worksheet.

i don't want press run , want control invocation based on 1 more macro (separate).

is possible , if yes, share insights regarding it.

this how worksheet looks , want invoke button separate macro:

this how worksheet looks , want invoke button separate macro

in order run macro attached activex control can directly call sub following command:

callbyname worksheets("sheet1"), "commandbutton21_click", vbmethod 

note, (by default) excel create private sub on worksheet button. if wish call these subs module have remove private up-front. note, sub's name must nameofthebutton_click.

so, if above code resides in sub in module , want make work the code on sheet (for example):

sub commandbutton21_click()  msgbox "gotcha"  end sub 

if wish invoke macros buttons on sheet1 following code do:

option explicit  public sub tmpso()  dim obj oleobject  each obj in worksheets("sheet1").oleobjects     if typename(obj.object) = "commandbutton"         callbyname worksheets("sheet1"), obj.name & "_click", vbmethod     end if next obj  end sub 

once again, make sure none of subs on sheet1 private. otherwise, these subs cannot called module merely sub resides on sheet1 well.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -