Python / COM / Word

Tim Golden tim.golden at viacom-outdoor.co.uk
Mon Mar 22 10:30:03 CET 2004


DS> I'm having a little trouble trying to automate Word 
DS> (2002).  I'm hoping to be able to create and process 
DS> documents relatively independently of any existing open 
DS> Word documents.
[...]
DS> Ideally I'd like to have independent 'Word instances', so I 
DS> can hack around to my heart's content without jeopardising 
DS> documents opened and created by some hapless user (which 
DS> would also be me).

I think this is what you want: (using Word2000, but I doubt it matters)

<interpreter dump>

ActivePython 2.2.3 Build 227 (ActiveState Corp.) based on
Python 2.2.3 (#42, Nov 13 2003, 09:57:55) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32com.client
>>> w1 = win32com.client.DispatchEx ("Word.Application")
>>> w1.Visible = True
>>> # (Word Appears; New Document; scribbles a bit...)
... w2 = win32com.client.DispatchEx ("Word.Application")
>>> w2.Visible
0
>>> w2.Visible = True
>>> # (second Word appears; another New doc. First one still untouched)
...
>>>

</interpreter dump>

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________




More information about the Python-list mailing list