ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Call subs from another wkbk? (https://www.excelbanter.com/excel-programming/308578-call-subs-another-wkbk.html)

Huyeote[_3_]

Call subs from another wkbk?
 
Hi call,

Any guru can tell me if I can call a sub in one workbook from anothe
workbook? If so, how?

Many thanks.

Huyeot

--
Message posted from http://www.ExcelForum.com


agarwaldvk[_22_]

Call subs from another wkbk?
 
As suggested by John Walkenbach in his book, there are 2 option
available to you :-

1. use the run method of the application object like so :-
application.run "full path name including the book name and the su
procedure name that you are trying to execute - all in double quote
with the book name in single quotes within the double quotes" as show
below :-

application.run "'c:\myfolder\myfile.xls'!myMacro"

This does not require for you to establish a reference to the referre
workbook.


2. Establish a reference to the desired workbook usin
Tools|References| and then browsing to find the desired workbook. Th
referred workbook doesn't need to be open for you to be able to use
sub in that workbook. Once the reference has been established say to
procedure called "myMacro", you can call the same by the followin
statement :-

call myMacro or simply
myMacro


Hope this helps!



Best regards




Deepak Agarwa

--
Message posted from http://www.ExcelForum.com


ForSale[_48_]

Call subs from another wkbk?
 
I know that i am not the one that posted the question, but i too wante
something similar. i tried both options and they both opened the fil
that contained the macro that was supposed to be run. is it possibl
to run a macro without opening the containing workbook

--
Message posted from http://www.ExcelForum.com


Myrna Larson

Call subs from another wkbk?
 
What is your ultimate goal? That the user doesn't see the new workbook on the
screen? If so, turn of screenupdating.

On Tue, 31 Aug 2004 21:50:21 -0500, ForSale
wrote:

I know that i am not the one that posted the question, but i too wanted
something similar. i tried both options and they both opened the file
that contained the macro that was supposed to be run. is it possible
to run a macro without opening the containing workbook?


---
Message posted from http://www.ExcelForum.com/



Tom Ogilvy

Call subs from another wkbk?
 
the short answer is no. The workbook has to be open to run the macro.
Myrna offers a workaround for not making it obvious that it is open.

--
Regards,
Tom Ogilvy

"ForSale " wrote in message
...
I know that i am not the one that posted the question, but i too wanted
something similar. i tried both options and they both opened the file
that contained the macro that was supposed to be run. is it possible
to run a macro without opening the containing workbook?


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 08:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com