ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run subroutines in other workbooks? (https://www.excelbanter.com/excel-programming/438758-run-subroutines-other-workbooks.html)

Robert Crandal

Run subroutines in other workbooks?
 
I have some code that initially opens another workbook, ie:

Set wb = Workbooks.Open ("myotherfile.xlsx")

This code opens the other workbook file and the "handle"
gets stored in the "wb" variable.

My question is, now that the workbook is open, how can
I run any of the subroutines in this other workbook???

(Assume that the "myotherfile.xlsx" file has a subroutine
named "Public Sub Foo (ByVal x as Integer)"... I would
like to call this function!)

Some have suggested that I need to use the Application.Run
method for this. Is that right?? How do I use that?

thank you



D_Rennie[_6_]

Run subroutines in other workbooks?
 

hello
try run [sub name] or call [sub name] withouth the []

cheers


--
D_Rennie
------------------------------------------------------------------------
D_Rennie's Profile: 1412
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=172755

Microsoft Office Help


Robert Crandal

Run subroutines in other workbooks?
 
But the subroutine is located in a different workbook (that is also
open).....
How do I specify the other workbook??

I thought it would be something like:

Workbooks("otherbook.xlsm").Run Foo, 1

But that doesn't seem to work....



"D_Rennie" wrote in message
...

hello
try run [sub name] or call [sub name] withouth the []

cheers



Bob Phillips[_4_]

Run subroutines in other workbooks?
 
Application.Run "otherbook.xlsm"!Foo",1

HTH

Bob

"Robert Crandal" wrote in message
...
But the subroutine is located in a different workbook (that is also
open).....
How do I specify the other workbook??

I thought it would be something like:

Workbooks("otherbook.xlsm").Run Foo, 1

But that doesn't seem to work....



"D_Rennie" wrote in message
...

hello
try run [sub name] or call [sub name] withouth the []

cheers





Bob Phillips[_4_]

Run subroutines in other workbooks?
 
Sorry type there, should have been

Application.Run "otherworkbook.xlsm!Foo",1

HTH

Bob


"Robert Crandal" wrote in message
...
But the subroutine is located in a different workbook (that is also
open).....
How do I specify the other workbook??

I thought it would be something like:

Workbooks("otherbook.xlsm").Run Foo, 1

But that doesn't seem to work....



"D_Rennie" wrote in message
...

hello
try run [sub name] or call [sub name] withouth the []

cheers





Paul

Run subroutines in other workbooks?
 
Don't forget that, with files that contain such characters as spaces, you'll
need to add quotes :

Application.Run "'My Other Workbook.xlsm'!Foo",1

--
If the post is helpful, please consider donating something to an animal
charity on my behalf.


"Bob Phillips" wrote:

Sorry type there, should have been

Application.Run "otherworkbook.xlsm!Foo",1

HTH

Bob


"Robert Crandal" wrote in message
...
But the subroutine is located in a different workbook (that is also
open).....
How do I specify the other workbook??

I thought it would be something like:

Workbooks("otherbook.xlsm").Run Foo, 1

But that doesn't seem to work....



"D_Rennie" wrote in message
...

hello
try run [sub name] or call [sub name] withouth the []

cheers




.



All times are GMT +1. The time now is 01:18 AM.

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