Run an Excel macro from Chemistation
Posted: Fri Sep 09, 2011 5:01 pm
Does anyone knows how to run an Excel macro from Chemstation.
I am going to run a macro named “mytest” in an Excel file. Below is my code. I tried RunExcelMacro() function and DDEExecute, both of them did not work. My Chemstation version is D.01.02. Does anyone knows what is the problem? Thanks.
local excel$,myPath$,myFile$,MyString$
excel$="C:\Program Files\Microsoft Office\Office\excel.exe "
myPath$="c:\temp\"
myFile$="test.xls"
excel$=excel$ + myPath$+ myFile$
a=exec(excel$,2)
chan = ddeinitiate("excel"+val$(a), myFile$)
! DDEExecute chan, [RUN("Mytest")]
print RunExcelMacro(chan, "Mytest")
DDETerminate Chan ! Close the channel
Remove excel$,myPath$,myFile$,MyString$
I am going to run a macro named “mytest” in an Excel file. Below is my code. I tried RunExcelMacro() function and DDEExecute, both of them did not work. My Chemstation version is D.01.02. Does anyone knows what is the problem? Thanks.
local excel$,myPath$,myFile$,MyString$
excel$="C:\Program Files\Microsoft Office\Office\excel.exe "
myPath$="c:\temp\"
myFile$="test.xls"
excel$=excel$ + myPath$+ myFile$
a=exec(excel$,2)
chan = ddeinitiate("excel"+val$(a), myFile$)
! DDEExecute chan, [RUN("Mytest")]
print RunExcelMacro(chan, "Mytest")
DDETerminate Chan ! Close the channel
Remove excel$,myPath$,myFile$,MyString$