Peut-on lancer scilab depuis excel ?
Can scilab be launched from excel ?
Merci / Thanks
Fred
yes
That would be a good thing.
I have calculations to make with excel that take too much times ( more
than 10 s ). So I have made a .sce file and want excel to launch the
script.
How can it be done ?
Can you explain it to me or give me an example ?
Thank you for all.
Fred
I have tryied to launch scilab with that VBA code :
Sub lance_programme()
monprogramme = "C:\Program Files\scilab-4.1\bin\WScilex.exe "
Shell monprogramme
End Sub
It works. But how can i launch a .sce file ?
Fred
try
Sub lance_programme()
monprogramme = "C:\Program Files\scilab-4.1\bin\WScilex.exe -f machin.sce"
Shell monprogramme
End Sub
or
Sub lance_programme()
monprogramme = "C:\Program Files\scilab-4.1\bin\WScilex.exe "
Shell monprogramme -f machin.sce
End Sub
S.
monscript = "C:\Program Files\scilab-4.1\bin\WScilex.exe -X C:
\derive.sce"
but scilab answers :
Startup execution:
loading initial environment
Warning !!!
Scilab has found a critical error (EXCEPTION_ACCESS_VIOLATION).
Scilab may become unstable.
And scilab don't begin the execution of the sce file..
Fred
I put -X because it is what is in the shortsut of a sce file in my
test folder.
Whit -f, that doesn't work neither. See below the scilab 's answer :
-----------------------------------------------------------------------------------------------------------------------------
___________________________________________
scilab-4.1
Copyright (c) 1989-2006
Consortium Scilab (INRIA, ENPC)
___________________________________________
Startup execution:
loading initial environment
!--error 276
Missing operator, comma, or semicolon
-----------------------------------------------------------------------------------------------------------------------------
I don't know how Excel passes arguments to scripts, it seems
to be the problem here.
S.
I agree with you and I am trying to look in that direction to solve my
problem.
this may help
open excel and populate cells a1 to c3 with data
use dde poke command to pass data to excel
i'll mess with it some more and try to pass a matrix to excel in one
chunk
http://wiki.tcl.tk/996 for more info
the commands that DDE passes to excel are excel macros
i think that they are the old excel 4.0 macros
--------------------------------------------------------------------------------------------------------------------
mode(-1);
TCL_EvalStr("package require dde");
// get a list of DDE services offered by excel
TCL_EvalStr("set a [dde services Excel """"] ");
b = TCL_GetVar("a");
mprintf(b);
// retrieve a1:c3
TCL_EvalStr("set a [dde request Excel {[Book1]Sheet1}
""R1C1:R3C3""] ");
b = TCL_GetVar("a");
mprintf(b);
// retrieve a1:c3 again
TCL_EvalStr("set a [dde request Excel Sheet1 ""R1C1:R3C3""] ");
b = TCL_GetVar("a");
mprintf(b);
// see this link about DDE
--------------------------------------------------------------------------------------------------------------------
js:)
hi, me again
here is a working snippet
fill some data into range A1:C3
//
--------------------------------------------------------------------------------------------------------------------
mode(-1);
TCL_EvalStr("package require dde");
TCL_EvalStr("set x [dde services Excel """"] ");
b = TCL_GetVar("x");
mprintf(b);
TCL_EvalStr("set x [dde request Excel {[Book1]Sheet1}
""R1C1:R3C3""] ");
b = TCL_GetVar("x");
mprintf(b);
TCL_EvalStr("set x [dde request Excel Sheet1 R1C1:R3C3 ] ");
b = TCL_GetVar("x");
mprintf(b);
TCL_EvalStr("set x [dde poke Excel Sheet1 R6C1:R99C99 """ + b +
""" ] ");
TCL_EvalStr("set x [dde poke Excel Sheet1 R4C5 3456 ] ");
tab = ascii(9); // tab character
nl = ascii(10); // newline character (cr (ascii 13) works too)
// assemble data to put into spreadsheet / 'tabs' separate cells /
'newlines' separate rows /
data = 'this' +tab+ 'is' +tab+ 'row' +tab+ 'one' +nl+ 'this' +tab+
'is' +tab+ 'the' +tab+ 'next' +tab+ 'row';
// another way
row1 = 'this' +tab+ 'is' +tab+ 'row' +tab+ 'one' +tab+
string(1425364) +tab+ string(3847566787);
row2 = 'this' +tab+ 'is' +tab+ 'the' +tab+ 'next' +tab+ 'row';
row3 = 'another' +tab+ 'row';
data = row1 + nl + row2 + nl + row3;
// !!!!!!!!! following range fills blanks up to R20C20 !!! make
the actual size you need
a = 'set x [dde poke Excel Sheet1 R11C1:r20c20 ""' + data + '"" ]
';
TCL_EvalStr(a);
// see this link about DDE
//
--------------------------------------------------------------------------------------------------------------------
regards
js:)
http://rcom.univie.ac.at
has a prerelease version in the download area.
http://rcom.univie.ac.at/download/devel/RSrv250PR2.exe
Since it is prerelease,
it might be somewhat rough,
but it contains instructions and a demo for Scilab.
The facility is NOT restricted to Excel.
Scilab is accessible as COM server which means
any program which can act as a COM client can access it.
This includes all MSOffice applications and all programming languages
included in Visual Studio.