Auto run macro
Here is my code
Sub Workbook_Open()
txttemp = ThisWorkbook.Path & Application.PathSeparator & "WorkBook2.xls"
Application.Run txttemp!Workbook_Analysis
End Sub
Workbook_Analysis is the macro name
I want the file is auto open too. The first line works. The second line
doesn't work now.
In my opionion the second line might need to put something for the
concatenetion.
Anyways, please give me suggestion.
Thanks,
March
"Dave Peterson" wrote:
Inside the second workbook's project:
Dim OtherWkbk as workbook
set otherwkbk = workbooks("otherworkbookname.xls") '<-- it has to be open
application.run "'" & otherwkbk.name & "'!somemacronamehere"
or
application.run "'" & otherwkbk.name & "'!somemacronamehere", myargument
or to return something:
dim resp as long 'or string or whatever
resp = application.run("'" & otherwkbk.name & "'!somemacronamehere", _
myargument)
March wrote:
Dear All,
I want to run automated macro in two workbooks. I means I have two workbooks
one centain macro and another one does not for now.
For the second one, I want to write VBA to call the Macro function from the
first one. I don't know what should I start now.
Please give me suggestion.
Thanks,
March
--
Dave Peterson
|