wxPython starting MS Word w/command args

We just did this with Word using Mark Hammond's win32com stuff.

Go to http://starship.python.net/crew/mhammond/win32/Downloads.html

I probably shouldn't be posting this because I don't remember the exact details but it is easy to download and install and he has provided good documentation on how to use it.

The only problem is the python COM browser isn't working in Python 2.4 so there is no direct way to know what methods are available. I just keep Word open with the macro editor open to verify the method names.

It's as simple as (descriptively speaking):

1) create an object using the COM client stuff with the name, e.g. "Word.Application". (I don't remember the name of the method to use right now.)
2) Set the "Visible" property to 1, e.g. o.Visible = 1
3) In the case of Word open a document with "Documents.Open(path)", such as o.Documents.Open(path). ("path" has to be the fully qualified path).

That's all there is to it. The Word object model can be confusing at times. I haven't done much with Excel.

I hope this helps.
-Rick King
Southfield MI

···

Wow,

I'd be fascinated to see how you automate Word and inserting stuff in
the template. I would like to do something similar with an Excel
template, but haven't had the courage to tackle figuring out how to
use the com interface.

Would you be willing to share? No problem if not.
-Jim

On Fri, 21 Jan 2005 15:28:40 -0500, Peter Herndon > <tpherndon@optonline.net> wrote:
> On Fri, 2005-01-21 at 13:02 -0500, Bill Tate wrote:
>
> > - a wxpython application create data source and header source files
> > required by Word mail merge feature
> >
> > - A separately compiled pythonwin application (compiled as an exe file
> > using pythonwin ala Mark Hammond') would be started by the wxpython
> > application – the wxpython application would need to supply some
> > command args along the lines of say >mypthonword.exe
> > myTemplateFile.doc myHeaderSource.doc myDataSource.doc to start word
> > so that the pythonwin application does the requisite processing
> >
> >
> >
> > I'm sure this is a convoluted way of doing things so I would certainly
> > welcome any suggestions as to how I might do this in the cleanest way
> > possible. Thanks in advance.
>
> I'm not sure I'd bother with a separate application. Use win32com to
> automate Word directly. I'm using that technique in two separate
> applications, one that scripts Word by starting Word, opening a template
> I built, and replacing bookmarks in the template with data. The second
> application does much the same with Excel, except there I'm just doing
> direct data insertion into certain cells. In both cases I wrote a
> module that handles all the COM automation tasks.
>
> The Python Programming for Windows book is your friend, in this case.
>
> HTH,
>
> ---Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org