I'm trying to call Mathematica functions from VBA (Excel) using .NETLink without success.
(Yes, I know Mathematica Link for Excel exists. And yes, I know the proper thing to do is buy it. However, it's not listed as compatible with v9, and on top of that, Episoft's website hasn't been updated since the end of 2011, so I'm not sure I want to rely on that for a long-term solution.)
Reading the .NET/Link API documentation is akin to hieroglyphics, and the information out there on how to hook up the two is pretty sparse.
I've narrowed it down to these items (after studying the SimpleLink example program included with Mathematica.
- Reference needed to NETLink .dll file (located under
FileNameJoin[{$InstallationDirectory, "SystemFiles", "Links", "NETLink"}]
) - Using
MathKernel.Compute()
andMathKernel.Results()
as main functions to send data back and forth.
When I set this up in VBA, I get the ever-present error "Can't find DLL entry point".
Public Declare Sub MMACompute Lib "C:\Program Files\Wolfram Research\Mathematica\9.0\SystemFiles\Links\NETLink\Wolfram.NETLink.dll" Alias "MathKernel.Compute" (expr As String)
Public Declare Function MMAResults Lib "C:\Program Files\Wolfram Research\Mathematica\9.0\SystemFiles\Links\NETLink\Wolfram.NETLink.dll" Alias "MathKernel.Result" ()
Sub test()
MMACompute ("2+2")
Debug.Print MMAResults()
End Sub
Any experience out there in getting this set up correctly? (Win7 x64, Office 2007 32-bit, MMA v9.01)
Install
when you runInstallNET[]
. I'm almost certain it's not used for what you're using it here. $\endgroup$