ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hard Code DLL Reference in VBA (https://www.excelbanter.com/excel-programming/301033-hard-code-dll-reference-vba.html)

ALEX

Hard Code DLL Reference in VBA
 
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

Papou

Hard Code DLL Reference in VBA
 
Hello Alex
Try
ThisWorkbook.VBProject.References.AddFromFile "Your Path\YourFile.dll"

HTH

Regards
Pascal

"alex" a écrit dans le message de
...
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




alex

Hard Code DLL Reference in VBA
 
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

Michel Pierron[_2_]

Hard Code DLL Reference in VBA
 
Hello Alex
Try
With ThisWorkbook.VBProject
.References.Remove .References("ProgressIndicator") ' or v.Name
End With

MP

"alex" a écrit dans le message de
...
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




Michel Pierron[_2_]

Hard Code DLL Reference in VBA
 
Re Alex,
With ThisWorkbook.VBProject.References
.Remove .Item("ProgressIndicator")
End With
MP

"alex" a écrit dans le message de
...
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





All times are GMT +1. The time now is 07:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com