Python as VBA replacement under Windows?

Discussion in 'Python' started by Wolfgang Keller, Aug 17, 2005.

  1. 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
     
    Wolfgang Keller, Aug 17, 2005
    #1
    1. Advertising

  2. "Wolfgang Keller" <> wrote in message
    news:...
    > 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
     
    Thomas Bartkus, Aug 17, 2005
    #2
    1. Advertising

  3. > 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
     
    Wolfgang Keller, Aug 17, 2005
    #3
  4. "Wolfgang Keller" <> wrote in message
    news:...
    > > 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
     
    Thomas Bartkus, Aug 17, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eugeni Doljenko

    Python as VBA replacement

    Eugeni Doljenko, Oct 5, 2004, in forum: Python
    Replies:
    0
    Views:
    371
    Eugeni Doljenko
    Oct 5, 2004
  2. guy lateur
    Replies:
    12
    Views:
    1,254
    guy lateur
    Jun 28, 2005
  3. Johannes Findeisen

    Re: Python vs. Access VBA

    Johannes Findeisen, Jul 17, 2005, in forum: Python
    Replies:
    0
    Views:
    937
    Johannes Findeisen
    Jul 17, 2005
  4. Chris Lambacher

    Re: Python vs. Access VBA

    Chris Lambacher, Jul 17, 2005, in forum: Python
    Replies:
    0
    Views:
    468
    Chris Lambacher
    Jul 17, 2005
  5. b wreath
    Replies:
    3
    Views:
    189
    Ben Morrow
    Jun 2, 2004
Loading...

Share This Page