Reputation: 1
I'm quite new to c++ and really new to creating DLL files. As a training excercise I tried to create a simple excel function that multiplies input data with 12. However excel keeps throwing up value errors.
I think I'm having a problem similar to using C++ 2010 dll in excel. I followed the instructions in www.maths.manchester.ac.uk/~ahazel/EXCEL_C++.pdf to create the code and when it didn't work I simplified it further.
my cpp file is:
#include "stdafx.h"
using namespace std;
static int _stdcall Multiply(int x)
{
int a = 12;
return a*x;
}
My DEF file is:
LIBRARY DLLtest
EXPORTS
Multiply
And lastly my VBA code is:
Declare Function Multiply _
Lib "C:\Users\[path]\Debug\DLLtest.dll" _
(ByVal x As Integer) As Integer
edit: I should probably add that I'm using excel 2010 and visual studio express 2013. The c++ code also came with some prebuilt code in dllmain.cpp and stdafx.cpp but I'm assuming this is not the problem.
Upvotes: 0
Views: 42