executing VBScript from Python and vice versa
Paul Paterson
paulpaterson at users.sourceforge.net
Fri Feb 4 19:52:46 EST 2005
Valentina Boycheva wrote:
> Is there a way to make programs written in these two languages communicate
> with each other? I am pretty sure that VBScript can access a Python script
> because Python is COM compliant. On the other hand, Python might be able to
> call a VBScript through WSH. Can somebody provide a simple example? I have
> exactly 4 days of experience in Python (and fortunately, much more in VB6)
>
> Thanks.
>
This should help for Python accessing VBScript,
>>> import win32com.client
>>> vbhost = win32com.client.Dispatch("ScriptControl")
>>> vbhost.language = "vbscript"
>>> vbhost.addcode("Function two(x)\ntwo=2*x\nEnd Function\n")
>>> vbhost.eval("two(2)")
4
>>>
Alternatively you could try to convert your VBScript to Python.
http://vb2py.sourceforge.net/demo.htm
Regards,
Paul
More information about the Python-list
mailing list