Application.Run with multiple workbooks
in my test, book2 has a sub called 'HelloWorld'
from another open workbook
Application.Run "book2!HelloWorld"
The sub must be public (which is the default) and must be
in a standard code module
Patrick Molloy
Microsoft Excel MVP
-------------------
I Feel Great
-----Original Message-----
I have a problem with the Application.Run method. If you
have two workbooks open, each with a code module,
Application.Run seems to only work with one of the
workbooks at a time and Application.Activate does not
change which module's procedures will work.
For example, open Excel 2000 (Book1) go to the VBA
editor and type workbooks.add in the debug window. Add a
module to each of the VBAprojects. Put Sub A containing
msgbox("A") in one module and Sub B containing Msgbox
("B") in the other.
Type Call A in the immediate pane and you get "Sub or
function not defined". Workbooks(1).activate does not
help. Using the syntax project.module.procedure does not
help either.
I need to call a procedure in the second Project from a
procedure in the first using Application.Run(ProcName) -
how do I do it?
.
|