I am using C++ to create a simple DLL that I can use from VBA code. However, while it works on my development computer, when attempting to access the DLL on different computers, VBA states the DLL File was not found, despite hardcoding the path in.
My DLL looks like this (created with Visual C++ 2010 Express as a Win32 dll project):
DEF file:
LIBRARY "squareNumber"
EXPORTS
squareNumber
Function.cpp:
double __stdcall squareNumber(double & x)
{
return x*x;
}
The VBA code looks like this:
Public Declare Function squareNumber Lib "C:\MySimpleDLL.dll" (ByRef number As Double) As Double
Sub test()
MsgBox squareNumber(2)
End Sub
I am very new to C++ DLLs, did I code the dll wrong, or is it VBA's problem?
Using RegSvr32 also yields "The module [dllpath] failed to load. Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files."