[python-win32] How to call Python methods and properties from VBS?

Mark Hammond mhammond at skippinet.com.au
Tue Sep 6 06:24:03 CEST 2011

Please keep replies on the python-win32 list - others may also be able 
to help you too.

You might like to check out the sample in samples\pywin32\com_server in 
the py2exe distribution - that demonstrates a simple COM object and has 
a VBScript sample which calls it.

Hope this helps,


On 6/09/2011 1:38 PM, FT wrote:
> Hi Mark,
>      I wanted to have the python and other modules from a py2exe accessible
> from vb script. So I would need to have the best documentation on how to set
> up the python com library to be able to call it from vb script. This is not
> using a web server, but inside a screen reader script language. The one I am
> using is Windoweyes Scripting language which has all or most windows methods
> and the external xml file for screen displays.
>      I am a blind programmer and use the screen reader with a built in vb
> script programming language. So, knowing Python I want to be able to call
> those module methods at will. I have made executables but they reside in a
> sub directory of Windoweyes and are limited to only what the .exe file does
> and not flexible beyond that point.
>      I was given snap shots of examples but they are very spotty and actual
> say they show a vb script example, but none was displayed.
>      I am assuming that you have to make a class for all the modules you want
> to be able to call, but not really sure on that. I have spent all evening
> trying to find examples and such and came up with almost nothing but an old
> activestate 2.4 brief description which said little on what to do.
>      So, this is where I am at the moment and have found little to explain
> fully what to do. It showed a way to set up the py2exe but the so called
> example call from vb script was not there but it said it was. The typical
> hello script example.
>      So, what I need is a very good tutorial on how to step by step make the
> class and compile it to a distributle so it can be registered and called as
> a com or automation call from vb script. Using what I would assume to be the
> CreatObject command in vbs to make an instance of that object/module/method.
>      I am blind, so no pictures, I need just plain text to do it.
>          Sincerely
>          Bruce
> Sent: Monday, September 05, 2011 6:51 PM
> Subject: Re: [python-win32] How to call Python methods and properties from
> VBS?
> On 4/09/2011 11:35 PM, FT wrote:
>> Hi Again,
>> To be more specific I have compiled the Python inside a distributed
>> package and need to know how to call from within that compiled package
>> any method. In other words do I have to register the Python inside my
>> .vbs script before calling any methods?
>> I am saying this so another user does not need to install Python, just
>> call using com inside the distributed Python compiled version.
>> If so, how do I get the Python setup or in a form to call? I will be
>> doing all the calls from .VBS and how would the CreateObject from there
>> be done to setup to call the compiled Python interpreter?
> You should develop and test using normal Python, then once you want to
> distribute it to others, look into py2exe to "compile" it and an
> installer program such as nsis or inno so the user can simply install it.
> Hope this helps,
> Mark

More information about the python-win32 mailing list