Problem with loading C++ dll from VBA

Arijeet
06-02-2010, 10:51 AM
Hi,

I have 2 .dlls in C++ which I am calling from VBA in Excel.

One is MyStDll.dll, a very light-wight dll with 1 exported function only.
The other is a heavy sgwindll.dll, which calls many other dlls.

The way I am calling them from my VBA code is:

Private Declare Function AddLongs_Pointer Lib
"c:\sgw\MyStDll\Debug\MyStDll.dll" _
(FirstElement As Long, ByVal lElements As Long) As Long

Private Declare Function AddLongs_Pointer Lib
"c:\sgw\test1\Debug\sgwindll.dll" _
(FirstElement() As Long, lSum As Long) As Long

The problem is with the loading of the sgwindll.dll

I can put the MyStDll.dll in any location and as long as I give the correct path after Lib, VBA is able to load the dll and execute the function operation.

But, in case of the sgwindll.dll, I have to place it in the same directory as EXCEL.EXE. In case I put the sgwindll.dll (and all required dlls) in a different location, I get Error 48: Error in loading DLL.

Am I missing something? Please help.

Cerian Knight
06-02-2010, 11:16 AM
In some other location, did you try (from a command prompt): Regsvr32 {Your Pathspec}\sgwindll.dll

Have a look here for additional info and more options:
http://www.xcelfiles.com/HowTo_01.html#anchor_23

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum