My Excel spreadsheet has a module (called MyModule) that requires a Reference to be added in order to work. If that Reference is not loaded, I will get this error upon opening the workbook:
Compile error in hidden module: MyModule
So I tried to add the following to Workbook_Open()
in ThisWorkbook
, such that the Reference will be added upon workbook open:
ActiveWorkbook.Application.VBE.ActiveVBProject.References.AddFromFile pathToMyReference
However, I am still getting the same compile error message. Is there a way to truly add the Reference before the spreadsheet is open?