View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default Launch Click Event Using Application.Run

First, you need to supply the path to "Budget Payee Names.xls" along with the
filename.

If supplying the path also doesn't make it work, then I suspect the problem
is that cbAddPayee_Click() is a Private sub, and therefore accessible only to
other procedures in the module where it is declared. Create a PUblic sub in a
general VBA module and put the essential code from cbAddPayee_Click() in it.
You may have to tweak it for sheet and cell references since it isn't in the
module attached to a particular sheet any more. Then you can call it from the
cbAddPayee_Click event and also from the other workbook using Application.Run.

Hope this helps,

Hutch

"cellist" wrote:

I want to launch the code that handles a
Click Event procedure defined in one
workbook from another workbook. The
Click Event handler is defined in
workbook "Budget Payee Names.xls" and is
named cbAddPayee_Click.

Private Sub cbAddPayee_Click()
MsgBox "entered cbAddPayee_Click"
End Sub

When I run the following code in the
"other" workbook I get error 1004.

Sub launchAddPayee()
Application.Run "'Budget Payee Names.xls'" & _
"!cbAddPayee_Click"
End Sub

Run-time error '1004':
The macro "Budget Payee Names.xls
'!cbAddPayee_Click' cannot be found.

I think I've ruled out the usual suspects -- syntax error, subroutine name
typo. I've also tried the code with and without the "Private" on the click
event sub. Does the target of application.run need to be in a module, as
opposed to code that resides within the "sheet"?

Any help will be appreciated,

Phil