Re: Linking to Mathematica Kernel from Excel
- To: mathgroup at smc.vnet.net
- Subject: [mg59647] Re: Linking to Mathematica Kernel from Excel
- From: Steve Kass <skass at drew.edu>
- Date: Tue, 16 Aug 2005 04:39:28 -0400 (EDT)
- References: <200508100658.CAA04724@smc.vnet.net><ddf5bp$ol0$1@smc.vnet.net> <ddk867$15l$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
stevekass at gmail.com wrote: > Murray, > > Can you verify that "Mathematica Link for Excel" works correctly with > recent versions of Mathematica? > > I just tried installing Episoft's other offering, Mathematica for > ActiveX, and it is not working. The files in that product are all > dated from 1996-2000, and I want to find out if it still works. > For the record, Mathematica for ActiveX works now, and I no longer get "$NoLink". I can't figure out what changed - the Mathematica kernel and application were both connecting fine when I was having trouble before and still are now. I haven't yet done more than display a Mathematica result in a VBA MsgBox, but so far so good. SK > If you are using it successfully, can you mention whether you are doing > this via a network license for Mathematica? I'm getting a $NoLink > result, which suggests that Episoft's product and NetworkMathematica > aren't playing well together. > > Steve Kass > Drew University > skass at drew.edu > > Murray Eisenberg wrote: > >>If you'd rather pay than play, you could use the Wolfram add-on >>application "Mathematica Link for Excel". See: >>http://www.wolfram.com/products/applications/excel_link/ >> >>plizak wrote: >> >>>I'm trying to write code to link to Mathematica automatically from >>>within MS Excel. Here is the code I have so far (below - It's VBA >>>code). >>> >>>It does not work when I first open Excel, but if I have already >>>connected to the kernel prior and want to reconnect then it works. Do >>>I have to point to the location of the kernel? If so how? >>> >>>Also, Am I clearing variables properly? What command should I use in >>>Mathematica to clear all variables??? >>> >>>Thanks in advance, >>>Peter >>> >>>------ VBA code below -------------------------------------------- >>> >>> >>> >>>' If there is an error, go to "deal" >>>On Error GoTo deal >>> >>> result = Application.Run("Mathematica", "$Version") >>> Debug.Print result >>> >>> ' If there is no link, then connect to the Kernel >>> If result = "$NoLink" Then >>> ' Connect to the mathematica Kernel >>> Debug.Print "Connecting to Mathematica" >>> Application.Run "LinkOpenOrClose" >>> >>> ' If there is a link already, clear all variables >>> Else >>> ' Clear the contents of the mathematica kernel >>> Debug.Print "Clearing Memory" >>> FunInput = "Clear[ ""Global `*""]" >>> result = Application.Run("Mathematica", FunInput) >>> Debug.Print result >>> End If >>> >>> ' check the version just to make sure we have a link >>> result = Application.Run("Mathematica", "$Version") >>> >>> If result = "$NoLink" Then >>> MsgBox ("Error connecting to Mathematica Kernel. Please verify >>>Mathematica is installed and available and please try again.") >>> End If >>> >>> >>> Exit Sub >>> >>>' do the following if we encounter an error >>>deal: >>> >>> Debug.Print "Error Linking Mathematica: Error # ", Err >>> If Err = 1004 Then >>> result = Application.Run("Mathematica", "LinkOpenOrClose") >>> End If >>> >>> >> >>-- >>Murray Eisenberg murray at math.umass.edu >>Mathematics & Statistics Dept. >>Lederle Graduate Research Tower phone 413 549-1020 (H) >>University of Massachusetts 413 545-2859 (W) >>710 North Pleasant Street fax 413 545-1801 >>Amherst, MA 01003-9305 > >
- References:
- Linking to Mathematica Kernel from Excel
- From: "plizak" <plizak@gmail.com>
- Linking to Mathematica Kernel from Excel