ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Question about references (https://www.excelbanter.com/excel-programming/299748-question-about-references.html)

mark

Question about references
 
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

Bob Kilmer[_2_]

Question about references
 
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" wrote in message
...
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.

Thanks

Mark





All times are GMT +1. The time now is 03:24 AM.

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