View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JohnS-BelmontNC[_2_] JohnS-BelmontNC[_2_] is offline
external usenet poster
 
Posts: 5
Default Reference to dll object in VBA

I've written a VB6 app that is a dll (FinV4.dll) for an Excel application.
When I re-make the dll and then open Excel, the reference always comes back
as "MISSING: DLL for FinV4".

I can uncheck the reference, exit references dialog, re-enter References,
find the new reference, check it, exit References and all runs well.

Since this application will be used predominantly by others, what I would
like to do is delete the missing reference and connect to the proper
reference programatically. It will facilitate future updates to both the
workbook and the dll when sent to others.

What I've done so far is:

Public Sub ConnectToFinPlannerDLL()

with ThisWorkbook.VBProject.References
.Remove "C:\Program Files\FinV4.dll"
.AddFromFile "C:\Program Files\FinV4.dll"
end with

End Sub

The remove statement doesn't remove the reference although if I manually
remove the Missing reference and just run the .AddFromFile line it connects
to the new dll. I've tried different forms of the Remove statement but have
been unable to make it work.

I've also removed early binding to prevent errors on workbook startup for
the global variables used to connect to the classes in the dll.

Any help will be appreciated.

End Sub