Python as VBA replacement under Windows?

Thomas Bartkus thomasbartkus at comcast.net
Wed Aug 17 12:07:52 EDT 2005


"Wolfgang Keller" <wolfgang.keller.nospam at gmx.de> wrote in message
news:mn.8bf77d584d2edf8b.30301 at gmx.de...
> > Because the MS Office suite and a few (very few!) other applications
expose
> > their object models via COM, you can manipulate these programs with
Python
> > and other languages.  No applicatoin "supports VBA as a macro language".
>
> What I meant was that quite a lot of Windows applications (not only MS
> Office) allow to execute VBA scripts just like "macros" from within the
> application. What I want now is to write a "dummy" VBA script
> "container" that consists of/executes Python sourcecode by calling the
> Pythonwin interpreter.

I *think* you may want to approach this from the other way around.  If it
were me, I would write a Python app that initates, and maintains handles to,
the target Windows app.  The controlling Python app could then drop from
sight and respond as necessary to events occurring within the Windows app.
This is the way you would do it from an external VB app.

> > Rather - VBA is bundled and integrated with MS Office in order to
manipulate
> > COM.  You can use Python to do that too!
>
> Yup, from outside. What I would like to do is do it from "inside" the
> application.

I don't *think* this is possible.  Nor do I think this is worth worrying
about.  You write VB/VBA applications to work either from the inside (in
process) or the outside (out of process) with the former being somewhat more
efficient.  Unfortunately, this is where VBA with it's integrated editor is
woven into the warp and woof  of MS Office. You are stuck running "out of
process" with Python. But again, I don't really see this as being worth
worrying about.

> > "perfectly possible"?
>
> Well, at least as far as there's a COM interface and for someone who
> refuses to learn VB(A) but still wants to script Windows applications.

I have dabbled a bit using Python to control Excel.  But just a bit.  It's
just too easy to invoke VBA behind Excel and fire away - even if the
resulting code isn't nearly so elegant! Somewhere out there, is a project to
integrate Python into Visual Studio.  Microsoft has rewritten Visual Studio
to enable the integration of 3rd party languages.  That might hold some
promise for you although I have not been following developments here very
closely.

As for me - I'm sick of the directions MS is taking.  I'm looking to
Gnumeric/Python as an open source replacement to Excel/VBA :-)
Thomas Bartkus






More information about the Python-list mailing list