Hard Code DLL Reference in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I 've created a DLL (from VB6) which is basically a progress bar. If i want to use it i have to go to Tools--> References to reference it.

The problem is that if you are spreading the application to a number of people you can't go around referencing the dll again and again..
I copied the file to our server and referenced it from there but for each new user i have to re-reference it again

Is there any way to 'hard code' the reference so that it works 'straight from the box'?

Any advice much appreciated,
Regards,
Alex
 
Hello Alex
Try
ThisWorkbook.VBProject.References.AddFromFile "Your Path\YourFile.dll"

HTH

Regards
Pascal

alex said:
Hi,

I 've created a DLL (from VB6) which is basically a progress bar. If i
want to use it i have to go to Tools--> References to reference it.
The problem is that if you are spreading the application to a number of
people you can't go around referencing the dll again and again..
I copied the file to our server and referenced it from there but for each
new user i have to re-reference it again
 
thanks a million for that it works just fine!

one more question once i add it then at the end of the
procedures i also want to delete it

i tried to use the following:
i=0
For Each v In ThisWorkbook.VBProject.References
If v.Name = "ProgressIndicator" Then 'Which occurs OK
ThisWorkbook.VBProject.References.Remove v "or"
v.remove
End If
Next

in both of the above cases it doesn't delete the reference
and it comes up with errors.

Now the basic problem is that you can not DIM something as
a Reference (hence i DIM'd v as Variant) and since the
..Remove property needs a reference in order to delete it
that creates a problem.

any ideas?

once more i appreciate your advice!
Alex
 
Hello Alex
Try
With ThisWorkbook.VBProject
.References.Remove .References("ProgressIndicator") ' or v.Name
End With

MP
 
Re Alex,
With ThisWorkbook.VBProject.References
.Remove .Item("ProgressIndicator")
End With
MP
 

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

Back
Top