Can I still register a function in a DLL using ExecuteExcel4Macro REGISTER?
With the grateful help of witek I got this to work. This is what I did:
(1) Using Visual Studio Express 2010, I created a project called squareDLL consisting of:
square.c:
double _stdcall square (double x)
{
return x * x;
}
square.def:
LIBRARY "square"
EXPORTS
square
and stored it at this location:
C:\Users\Owner\Documents\Visual Studio 2010\Projects\squareDLL\Debug\squareDLL.dll
(2) In Excel I setup:
Private Sub Workbook_Open()
Dim sParm As String, sDQ As String
sDQ = Chr(34) 'Double quotes
sParm = ""
sParm = sParm & sDQ & "C:\Users\Owner\Documents\Visual Studio 2010\Projects\squareDLL\Debug\squareDLL.dll" & sDQ & ","
sParm = sParm & sDQ & "square" & sDQ & ","
sParm = sParm & sDQ & "BB" & sDQ & ","
sParm = sParm & sDQ & "square" & sDQ & ",,1"
Application.ExecuteExcel4Macro ("REGISTER(" & sParm & ")")
End Sub
(3) I was then able to use the square function, in a cell in my worksheet, like this:
=square(C2)
=square(45)
|