[python-win32] Compiling a Python Windows application

Bokverket bokverket at hotmail.com
Mon Nov 27 21:56:10 CET 2006


> Do I have to go through Visual Basic macros to do this
One does Word automation using VB. AFAIK there is no other way.
We can help guide you thru the steps (this is how I would do it):
- create UserForm(s) to collect parameters
- create a custom menu using Tools -> Customize with each item tied to a
macro
Each macro would open a userform. The click event of the OK button on
the UserForm would shell Python.

A slight alternative would be to have the macros call Windows Scripting
Host files that would present the dialog and shell Python.

A bigger alternative would be to have the macros shell Python and write
the parameter collecting mechanism in Python.

> or is there a _good_ way?!
I take it that you don't enjoy VB programming. It certainly is more
wordy and less flexible than Python, but for relatively small tasks like
this not a big deal. I've written 10s of thousands of lines of VBA for
Word and Access. Of course I prefer Python when I can use it.
-------------


ME:
Thanks very much for responding, Bob and James!

I did program a lot in VB's earlier versions, but it has grown... My reason 
for not considering VB was that the actual processing would make excellent 
use of the Python collection objects /dictionaries/, which in my mind would 
hold words of the Microsoft Word document. (The app's purpose is to analyze 
words of possibly very large Word documents.) Plus I suppose that a macro 
which would loop with a few lines over each word of the doc will be slow, 
although I don't if there is a compiling or byte-code mechanism.  Am I 
wrong?

I don't know if having a VB as glue to shelling Python is perfectly fine 
performance-wise, and it certainly would be a simple way to handle the 
dialog boxes that collect the parameters.  Maybe that is a much better way 
than wondering about calling Python /shelling, calling a DLL, whatever/ 
directly.

Next question: Is Microsoft Word's API for Python published like for VB and 
easy to use?

Best,

Göran /Goran with two dots/  :-)
Stockholm, Sweden



More information about the Python-win32 mailing list