Probelm with Application.Run Method

I

IComeInTheWest

Hello,

I'm having difficulty calling a procedure from a separate workbook.
Right now I have

Application.Run "'S-Report.xls'!Time_Phase"

but I'm getting the error message "The macro "'S-Report.xls'!
Time_Phase" cannot be found."

Any ideas?


Thanks,

Calvin
 
D

Dave Peterson

Is there a macro named Time_Phase in that S-Report.xls workbook's project?

Is s-report.xls open?
 
I

IComeInTheWest

Is there a macro named Time_Phase in that S-Report.xls workbook's project?

Is s-report.xls open?











--

Dave Peterson- Hide quoted text -

- Show quoted text -

Dave,

I got it to work, I had to use "...Time_Phase.Time_Phase". (My guess
is because both the module and the procedure had the same name.)

I have another question:

The Time_Phase macro begins with a vbYesNo message box. Is it possible
to automatically select "Yes" when calling the Time_Phase macro
externally as I am?

Thanks,

Calvin
 
J

Jon Peltier

You need to rewrite the macro to enable the dialog to be skipped. Perhaps
you could add an optional argument which runs the regular way if missing,
and runs without the dialog if present.

- Jon
 
I

IComeInTheWest

You need to rewrite the macro to enable the dialog to be skipped. Perhaps
you could add an optional argument which runs the regular way if missing,
and runs without the dialog if present.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -http://PeltierTech.com
_______








- Show quoted text -

I cannot alter the Time_Phase macro (the one being called externally).
Is there no way to automatically select "Yes" in an externally called
message box?
 
P

Peter T

Following worked in a light test, but SendKeys can never be considered
reliable -

'should 'click' default button1
Application.SendKeys "{RETURN}"

' otherwise try
' Application.SendKeys "%y"
Application.Run "myBoook.xls!myMacro"

' in myBoook.xls
Sub myMacro()
Dim answer As VbMsgBoxResult

answer = MsgBox("Respond", vbYesNoCancel)

' also try following
' answer = MsgBox("Respond", vbYesNoCancel or vbDefaultButton3)


Select Case answer
Case vbYes
MsgBox "yes"
Case vbCancel
MsgBox "cancel"
Case vbNo
MsgBox "no"
End Select

End Sub

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top