Assigning references with VBA code

G

Guest

Hello everyone. I am attempting to distribute an application on my company's
intranet but I am encountering a small problem. The app uses a .dll that is
not standard. I have therefore put the .dll in a self-extracting zip file and
posted it on the file server for the end users to run on their own machines.
My app checks for the .dll and "installs" if it is not already with the
following code:

refArray(0, 0) = "VBA"
refArray(0, 1) = "C:\Program Files\Common Files\Microsoft
Shared\VBA\VBA6\VBE6.DLL"
refArray(1, 0) = "Access"
refArray(1, 1) = "C:\Program Files\Microsoft Office\Office10\MSACC.OLB"
refArray(2, 0) = "stdole"
refArray(2, 1) = "C:\WINDOWS\system32\stdole2.tlb"
refArray(3, 0) = "DAO"
refArray(3, 1) = "C:\Program Files\Common Files\Microsoft
Shared\DAO\dao360.dll"
refArray(4, 0) = "ADODB"
refArray(4, 1) = "C:\Program Files\Common Files\System\ado\msado21.tlb"
refArray(5, 0) = "Excel"
refArray(5, 1) = "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE"
refArray(6, 0) = "CommonDialogDirect6"
refArray(6, 1) = "C:\CMDLGD6.dll"

For i = 0 To 6
isRefd = False
For Each ref In Application.References
If refArray(i, 0) = ref.Name Then
isRefd = True
End If
Next ref
If Not isRefd Then
Application.References.AddFromFile (refArray(i, 1))
End If
Next i

When I run the app from a different machine other than my own it does seem
to be referenced. However, I get an error message when the code that uses
that .dll is invoked. What is strange is that if I de-reference the .dll and
then re-reference it manually (Tools|References...) it works just fine. Does
anyone see an error in my code or does it just not work that way.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top