Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python as VBA replacement under Windows?

Reply
Thread Tools

Python as VBA replacement under Windows?

 
 
Wolfgang Keller
Guest
Posts: n/a
 
      08-17-2005
Hello,

this is a potentially veeery dumb question, but:

- If an application supports VBA as a macro language,
- and if you can execute Python code from within a VBA script (how?)
- and if the application exposes its VBA scripting interface through
COM

then it should be perfectly possible to entirely replace VBA in nearly
all Windows applications with Python, right?

TIA,

sincerely,

Wolfgang Keller


 
Reply With Quote
 
 
 
 
Thomas Bartkus
Guest
Posts: n/a
 
      08-17-2005
"Wolfgang Keller" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> this is a potentially veeery dumb question, but:
>
> - If an application supports VBA as a macro language,
> - and if you can execute Python code from within a VBA script (how?)
> - and if the application exposes its VBA scripting interface through
> COM
>
> then it should be perfectly possible to entirely replace VBA in nearly
> all Windows applications with Python, right?
>
> TIA,
>
> sincerely,
>
> Wolfgang Keller


"perfectly possible"? Hmmmhh!

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".
Rather - VBA is bundled and integrated with MS Office in order to manipulate
COM. You can use Python to do that too!

However

It is difficult to argue with the built in integrated editor/debugger behind
Excel, Word, PowerPoint, et al with the scripts packaged seamlessly inside
the application files. It's also difficult to argue with the myriad of
built in VBA functions that are custom designed to ease the pain of working
with Windows internals.

On the other hand

I can think of nothing that you can do with VBA but can not do with Python.
It just takes a bit more effort and you need to know more of Windows
internals in order to pull it off.

"perfectly possible"?

I'm still thinking
-Tom


 
Reply With Quote
 
 
 
 
Wolfgang Keller
Guest
Posts: n/a
 
      08-17-2005
> 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.

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

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

Sincerely,

Wolfgang Keller


 
Reply With Quote
 
Thomas Bartkus
Guest
Posts: n/a
 
      08-17-2005

"Wolfgang Keller" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> > 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Python vs. Access VBA Chris Lambacher Python 0 07-17-2005 03:48 PM
Re: Python vs. Access VBA Johannes Findeisen Python 0 07-16-2005 11:30 PM
Office COM automatisation - calling python from VBA guy lateur Python 12 06-28-2005 06:06 PM
Python as VBA replacement Eugeni Doljenko Python 0 10-05-2004 11:36 AM
Plotting data under VisualBasic 5.0 or the VBA included with MSWord97or MSAccess97 Richard Owlett Computer Support 0 10-01-2003 08:57 PM



Advertisments