executing VBScript from Python and vice versa

  • Thread starter Valentina Boycheva
  • Start date
V

Valentina Boycheva

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.
 
P

Paul Paterson

Valentina said:
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,

Alternatively you could try to convert your VBScript to Python.

http://vb2py.sourceforge.net/demo.htm

Regards,

Paul
 
N

News M Claveau /Hamster-P

Cool. :)

And it's OK, also, for JScript (MS-Javascript) :


import win32com.client

vbs = win32com.client.Dispatch("ScriptControl")
vbs.language = "vbscript"
scode="""Function mul2(x)
mul2=x*2
End Function
"""
vbs.addcode(scode)
print vbs.eval("mul2(123)")

js = win32com.client.Dispatch("ScriptControl")
js.language = "jscript"
scode="""function mul3(x){
vret=x*3;
return(vret);
}
function mul4(x){
vret=x*4;
return(vret);
}
"""
js.addcode(scode)
print js.eval("mul3(123);")
print js.eval("mul4(121);")





@-salutations
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,184
Messages
2,570,979
Members
47,580
Latest member
kim2namjoon

Latest Threads

Top