Using Relative Paths in Declare Statements
I noticed that VBA is really only happy when I use absolute paths to my homebrewed DLLs, like:
Code:
Declare Function myFunction1 Lib "C:\extremely\long\abs\path\to\DLL\myDLL.dll" _
(argList) As retType
Declare Function myFunction2 Lib "C:\extremely\long\abs\path\to\DLL\myDLL.dll" _
(argList) As retType
Declare Function myFunction3 Lib "C:\extremely\long\abs\path\to\DLL\myDLL.dll" _
(argList) As retType
To be honest, that's kind of a drag. Is there any way possible to use relative pathnames here? I'm really just after shortening the declare statement to make it more palatable. Even this would be an improvement:
Code:
Const myPath = "C:\extremely\long\abs\path\to\DLL"
Declare Function myFunction1 Lib myPath & "\myDLL.dll" (argList) As retType
Declare Function myFunction2 Lib myPath & "\myDLL.dll" (argList) As retType
Declare Function myFunction3 Lib myPath & "\myDLL.dll" (argList) As retType
Not to mention the fact that if I give someone my Excel document, they only need to change one line to get all the Declare statements to match their own filesystem structure instead of modifying a whole bunch of Declare statements. In this regard, a relative path name to the DLL would be fantastic....
Is there anything that can be done here to make the declarations a bit more user friendly?
Thanks!
Pete
Re: Using Relative Paths in Declare Statements
Assuming that it works the same way as in Classic VB... As long as you have actually registered the DLL (by running regsvr32, or by compiling it on that machine), you should simply be able to use the file name, with no path at all, eg:
Code:
Declare Function myFunction1 Lib "myDLL.dll" (argList) As retType