Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Load Dll
Does anyone know how can I load a dll from vba (excel)
Path: "C:\apps_pub\tn327080\ehllap32.dll I need to execute this function: WaitPSSync() Tks, Lisandro Oliveira. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Load Dll
What do you mean by load. Do you mean you want to open and read the file.
Or do you mean that you want to copy ehllap32.dll to the path that you show. Does WaitPSSync() require that the dll be in the directtory shown? "Lisandro Oliveira" wrote: Does anyone know how can I load a dll from vba (excel) Path: "C:\apps_pub\tn327080\ehllap32.dll I need to execute this function: WaitPSSync() Tks, Lisandro Oliveira. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Load Dll
You need to register the DLL if that hasn't been done.
Start | Run regsvr32 "C:\apps_pub\tn327080\ehllap32.dll" In the VBA Editor, check it using menu Tools | References. Declare and set an object of a public Class in the DLL, e.g.: Dim myObj As MyDLL.Class1 Set myObj = New MyDLL.Class1 Call the function (with any required arguments): y = myObj.Function1(x) When done: Set myObj = Nothing Hth, Merjet |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Load Dll
Hi Joel,
I need to read this dll and execute the WaitPSSync() function. This is the address "C:\apps_pub\tn327080\ehllap32.dll" where it is in my machine. regards, Lisandro "Joel" wrote: What do you mean by load. Do you mean you want to open and read the file. Or do you mean that you want to copy ehllap32.dll to the path that you show. Does WaitPSSync() require that the dll be in the directtory shown? "Lisandro Oliveira" wrote: Does anyone know how can I load a dll from vba (excel) Path: "C:\apps_pub\tn327080\ehllap32.dll I need to execute this function: WaitPSSync() Tks, Lisandro Oliveira. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Load Dll
The DLL is loaded when the Excel file is opened, provided there's a
declaration for the WaitPSSync function in your code, and the DLL is in either System32 or the same folder as the Excel file, in which case it's best to change the current directory to that folder by putting "ChDir ThisWorkbook.Path" in ThisWorkbook/Workbook_Open. You have to be careful and know the language/compiler with which the DLL was written, because the Declare statement in the VBA code has to have all parameters and the return type identical with respect to both type and calling convention (reference/value). In particular, C/C++'s default convention is by value, but VBA's is by reference (pointer). Worse yet, string parameters, which are pointers, should nevertheless be declared by value, because the parameter is actually a pointer. For example: Public Declare Function WaitPSSync Lib "ehllap32" As Long assumes it takes no parameters and returns a signed long but: Public Declare Sub WaitPSSync Lib "ehllap32" (ByVal LongParm As Long) takes a signed long and returns nothing. -- --Andy Smith "Lisandro Oliveira" wrote: Does anyone know how can I load a dll from vba (excel) Path: "C:\apps_pub\tn327080\ehllap32.dll I need to execute this function: WaitPSSync() Tks, Lisandro Oliveira. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Load Dll
Thanks for all!!!!!
I will try to do it. regards, Lisanro "Andy Smith" wrote: The DLL is loaded when the Excel file is opened, provided there's a declaration for the WaitPSSync function in your code, and the DLL is in either System32 or the same folder as the Excel file, in which case it's best to change the current directory to that folder by putting "ChDir ThisWorkbook.Path" in ThisWorkbook/Workbook_Open. You have to be careful and know the language/compiler with which the DLL was written, because the Declare statement in the VBA code has to have all parameters and the return type identical with respect to both type and calling convention (reference/value). In particular, C/C++'s default convention is by value, but VBA's is by reference (pointer). Worse yet, string parameters, which are pointers, should nevertheless be declared by value, because the parameter is actually a pointer. For example: Public Declare Function WaitPSSync Lib "ehllap32" As Long assumes it takes no parameters and returns a signed long but: Public Declare Sub WaitPSSync Lib "ehllap32" (ByVal LongParm As Long) takes a signed long and returns nothing. -- --Andy Smith "Lisandro Oliveira" wrote: Does anyone know how can I load a dll from vba (excel) Path: "C:\apps_pub\tn327080\ehllap32.dll I need to execute this function: WaitPSSync() Tks, Lisandro Oliveira. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I load an Add-ins | Excel Discussion (Misc queries) | |||
On load | Excel Programming | |||
Cannot load | Excel Discussion (Misc queries) | |||
load an add-in in VBA | Excel Programming | |||
How to load another XLL in the XLL? | Excel Programming |