PDA

View Full Version : EXCEL, VBA, DLL



GaAck
11-06-2015, 03:28 PM
Hallo,

I have some 32-bit-DLLs with complicated functions, which I use in an Excel-Spreadsheet. For this, I made a macro (VBA), which defines a function for the spreadsheet (user defined function) and this macro does not more than to calls the function in the DLL. Works fine.

Now I have to adapt it to 64-bit-systems. I decided, to use C++ and Visual Studio 2015 to make the DLL. (My original Pascal-Compiler does not support 64 bit and a change to C++ was very simple, there are only mathematical operations). I have read a lot, read posts in forums, tried a lot... no success. The macro runs, but I get "#WERT!" (I assume, in English versions "#VALUE!") in the cell. The problem seems to be in the fields "byval, byref", "stdcall, cdecl", "4- or 8-bit alignment" or any other of this kind.

Does anybody have an example which works? Any function "MyAdd(a1,a1 as double)" giving a1+a2 as result?

Would be great,
GaAck

Note: The algorithms are also used and tested (!!) in other programs, otherwise I could do it simply in an Excel-Makro.

Kenneth Hobs
11-06-2015, 07:05 PM
Welcome to the forum!

I have not made a 64bit DLL. If you want to try my 32bit simple example made in vb.net,see: http://www.vbaexpress.com/forum/showthread.php?45316-How-to-call-use-DLL-via-vba-macro&highlight=mathlib