Open WorkBook & Run Macro

M

Mike Fogleman

From code in one workbook I want to open another workbook and run a
procedure that is in it. I have this in the first workbook:
Sub RunTracking()
Dim cdir As String
Dim wb As Workbook

For Each wb In Workbooks
If wb.name = "NCP Tracking.xls" Then
MsgBox ("NCP Tracking.xls is already open.")
Exit Sub
End If
Next wb
cdir = ActiveWorkbook.Path
Workbooks.Open cdir & "\NCP Tracking.xls"
Application.Run ("RunUpdate")
End Sub

I also tried Application.Run ("NCP Tracking.xls!RunUpdate"), but still says
"Can not find"
What I gotta do?

Mike F
 
B

Bob Phillips

Mike,

it is the embedded spaces I think. Try

Application.Run ("'NCP Tracking.xls'!RunUpdate")

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
M

Mike Fogleman

Thanks Bob, that was it. Silly me tried to use the Help example for the Run
Method which says:
mySum = Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)
MsgBox "Macro result: " & mySumNo single quotes in that is there?Mike F"Bob
 
B

Bob Phillips

That's the main problem with help that I find, it always gives a basic
example, usually one that you can work out yourself, and never shows you how
to really push it.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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