Excel error linking C++: "A value used in the formula is of the wrong data type" -
i wrote simple c++ program
source.cpp:
double __stdcall square(double& x) { return x*x; }
define.def:
library "square" exports square
then in .xlsm file modules, added module1 imporing:
declare ptrsafe function square _ lib "c:\users\user\documents\athoscode\marek kolman square\square\debug\square.dll" _ (byref x double) double
and in sheet1, put 10
in a1, , =square(a1)
in b1.
the error says: "a value used in formula of wrong data type".
what's problem , how fix it?
my environment - windows 7 64-bits - visual studio 2016 community (so it's 32-bits) - excel 2016 64-bits
replying comment, if change passing reference passing value, error same.
i changed source.cpp to
double __stdcall square(double x) { return x*x; }
and changed module1 as
declare ptrsafe function square _ lib "c:\users\user\documents\athoscode\marek kolman square\square\debug\square.dll" _ (byval x double) double
same error.
due differences in architecture, it's impossible load 32-bit dll in 64-bit process , vice versa
it's possible access 32-bit dlls 64-bit code unless have legacy dlls without 64-bit version, should compile 64-bit project. , 64-bit office doesn't support 32-bit plugin @ all you'll need 64-bit dll.
Comments
Post a Comment