Question about references

G

Guest

From a sub routine in one workbook I want to call a public method that exists in a public subroutine within another workbook

The problem is that I don't want the user to have to manually add a reference to the called workbook before being able to make the call

The only way I have found to call from one workbook to another is to first select the called workbook in the VBA references dialog. Once manually referenced I can do something like workbook_with_manual_reference.the_public_method()

I am finding this is the case even when the called method exists within a workbook that is loaded as an add-in. Oddly enough, application events that are trapped within the add-in code get called regardless of whether the add-in is referenced or not

Is it possible to automatically create (late-bind) references to loaded workbooks? How do you do it? If it is possible then how do you late bind the called method such that the compiler does not complain about the missing reference while the dynamic reference is being created

Thank

Mark
 
B

Bob Kilmer

I believe you can use Application.Run to do that. Type Application.Run into
the immediate window, put your cursor on Run, then hit F1 to view the Help
article on Run.

Mark said:
From a sub routine in one workbook I want to call a public method that
exists in a public subroutine within another workbook.
The problem is that I don't want the user to have to manually add a
reference to the called workbook before being able to make the call.
The only way I have found to call from one workbook to another is to first
select the called workbook in the VBA references dialog. Once manually
referenced I can do something like
workbook_with_manual_reference.the_public_method().
I am finding this is the case even when the called method exists within a
workbook that is loaded as an add-in. Oddly enough, application events that
are trapped within the add-in code get called regardless of whether the
add-in is referenced or not.
Is it possible to automatically create (late-bind) references to loaded
workbooks? How do you do it? If it is possible then how do you late bind
the called method such that the compiler does not complain about the missing
reference while the dynamic reference is being created.
 

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