excel - Cannot add DLL reference with AddFromFile -
i trying use com visible .net dll excel vba. have been successful when registering dll using regasm , manually adding reference via tools -> references menu item in vba developer window.
however, trying register dll without using regasm command excel file can used on computer without registering dll. far i've tried:
dim jart_instance object sub initialize() dim refpath string, x byte const refname = "jart xxx" refpath = application.activeworkbook.path & "\jart\jart.dll" activeworkbook.vbproject.references x = 1 .count if .item(x).description refname .remove .item(x) end if next .addfromfile (refpath) end end sub sub postinitialize() set jart_instance = new jart.mainjobcontrol end sub
i have added reference "microsoft visual basic applications extensibility 5.3". when run above code "run-time error '48': error in loading dll". have loaded dll couple times using regasm. need change guid's used in project , retry. i've seen code examples supposed work.
if reference tlb file instead of .dll not dll loading error. instead error whenever try use jart_instance variable saying reference has not been set. though postinitialize gets called directly after initialize , there no evidence of code threw error or failed run. if try put "stop" command in postinitialize function tells me "cannot enter break-mode @ time".
any ideas, thanks.
excel-dna has helper function com addins written on platform.
it appears to:
- load addin
- register coregisterclassobject
- add it's progid registry
- add registry key hkcu\software\microsoft\office\excel\addins
- call application.comaddins.update in excel
- remove previous registry entries
- unregister object corevokeclassobject
it appear once excel has loaded addon, doesn't unload when registry entries removed , corevokeclassobject called. stays loaded until excel closes , releases it.
so, it's doable not easy.
Comments
Post a Comment