ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add reference programmatically before a module compiles (https://www.excelbanter.com/excel-programming/301392-add-reference-programmatically-before-module-compiles.html)

Wexler

Add reference programmatically before a module compiles
 
I created a dll with most of the code to run my excel application.
When you open the workbook, the first line adds a reference to the dll
programmatically:
ThisWorkbook.VBProject.References.AddFromFile ("C:\UDACO2004.dll")

This is easy. However, I have declared a public variable in another
module like this:
Public UDADLL As New UDACO2004.Estimating

Up until today, the workbook opened fine, added the reference, and
then proceeded to call the library functions. But today I get a
compile error: "user-defined type not defined", so I can't add the
reference because VBA tries to compile the declaration of that object
(which it didn't do before)

I know VBA compiles as needed at runtime, but is there any way to
ensure that a particulart module doesn't get compiled when you open a
workbook???


All times are GMT +1. The time now is 07:15 PM.

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