[python-win32] python ScriptControl error in Excel while runningfine in python

Sébastien de Menten sdementen at hotmail.com
Fri Feb 4 16:55:58 CET 2005


> > I am trying to use ScriptControl under Excel (Windows XP)
> > with the code:
> >
> > Global sc As New MSScriptControl.ScriptControl
> >
> > Public Function os_getcwd()
> >     sc.Language = "python"
> >     sc.ExecuteStatement ("import os")
> >     os_getcwd = sc.Eval("os.getcwd()")
> > End Function
> >
> > When setting the language to python I have the error "A
> > script engine for
> > the specified language..."
> >
> > On the other side, under python, the translated code:
> >
> > import win32com.client
> >
> > sc=win32com.client.Dispatch("ScriptControl")
> > sc.Language = "python"
> > sc.ExecuteStatement ("import os")
> > print sc.Eval("os.getcwd()")
> >
> > works without any problem !
> >
> > So, is it possible that a different set of permissions for languages
> > available in ScriptControl is used when executed from Excel
> > or from python ?
> > Is it possible to ask the available languages to ScriptControl ?
>
>I'm guessing that Excel is adding some restriction to the languages that 
>can
>be used - maybe only those marked "safe for scripting".
>
>If you register the ActiveScript engine with debugging
>(win32comext\axscript\client\pyscript.py --debug), and view the Pythonwin
>"Remote Trace Collector" tool, you may end up with additional clues - eg,
>maybe Python is being instantiated, but then queried for an unknown
>interface, or an attempt is made to make the engine "restricted", which
>would fail.

With debug enabled, I see the trace in the "Remote Trace Collector" when 
running the python script. But nothing happens when I run the VBA excel 
macro.
I guess the security feature is higher in the stack of calls but I do not 
have a clue on how to change it.

>
>Mark
>




More information about the Python-win32 mailing list