View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default VBA code to send click command to a macro in a different Excel workbook

A Sub procedure can be assigned to a shape or button, either
programmatically (via code) or by right-clicking the shape and
choosing "Assign Macro". If you know the name of the procedure
assigned to the shape or button, you can call that procedure directly,
by-passing the shape entirely. If you don't know the name of the
procedure, right-click the shape and choose "Assign Macro" and the
assigned macro name will be displayed. Once you know that, just use in
your code something like:

Sub ABC()
' your code
Application.Run "TheProcName"
' more code
End Sub

where "TheProcName" is the procedure assigned to your shape or button.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Sat, 19 Sep 2009 17:03:35 -0700, Will Anikouchine wrote:

My problem is the same as Raj's. I wish to write code in VBA to, in effect, remotely click a command button on a different worksheet. I needd a bit more guidance than "see help for Application.Run". I don't even know where to find that.

Any help would be greatly appreciated.



Posted as a reply to:

Macro code for clicking on Command Button in another workbook

Hi,

I have a workbook with macros. The macros open another workbook with
macros created by another person with code protected. A sheet in that
workbook has a command button that is to be clicked to run the macros
in that workbook. Is there a programmatic way by which I can click the
command button from my workbook macro code?

Thanks in Advance for the Help.

Regards,
Raj

EggHeadCafe - Software Developer Portal of Choice
WCF Workflow Services Using External Data Exchange
http://www.eggheadcafe.com/tutorials...vices-usi.aspx