Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Controlling Excel Add-In Loading

  Asked By: Ruben    Date: Oct 13    Category: MS Office    Views: 863
  

I have a .dll file here that I want to reference in my Excel file.
All I do is just click Tools >> References and then locate the .dll
file to include it in the list.

No problem there. Got my code in the .dll file to work just fine.

The problem here is that if I move the location of the Excel file and
the .dll file, whether it be in another PC on the network or just
another folder on my hard drive, my Excel macro crashes. It won't run
because I changed the location of the .dll file.

I'm guessing I need to do some late binding eh? The problem is how...

Here's the code:
---------------------------------------------------

'I declared these public so I can use it anywhere on my workbook.
Public dllFunction As TemplateDll.cmFunctions
Public dllProcedure As TemplateDll.cmProcedures

Private Sub Workbook_Open()
'Assigned the references to variables
Set dllFunction = New TemplateDll.cmFunctions
Set dllProcedure = New TemplateDll.cmProcedures
End Sub

---------------------------------------------------

The code above works just fine...I just need it to work whenever I
move BOTH my Excel file and my .dll file anywhere on my hard drive or
on network...

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Chau Tran     Answered On: Oct 13

Here is some code  that I have used in an Excel file  because I didn't know
what version of Outlook the users were going to be using:

#If EarlyBinding = 1 Then
Public objOLapp As Outlook.Application
Public objOLitem As Outlook.MailItem
#Else
Public objOLapp As Object
Public objOLitem As Object
#End If

Quoted from David Horowitz:
Where EarlyBinding is a compiler option in the project properties
(Tools/Properties for ...). When I develop I use EarlyBinding = 1 and have a
reference to the, in this case, version of Outlook on my computer. You have
all the method and properties with intellisense at your disposal. When
delivering the app I erase the references  and set the compiler option to
EarlyBinding = 0. And voila, no changes to the code because of the public
declarations (object and constants) and RUN!

 
Didn't find what you were looking for? Find more on Controlling Excel Add-In Loading Or get search suggestion and latest updates.




Tagged: