Finding Word and switch focus to it

Hughes, Chad O chad.hughes at pnl.gov
Wed Jun 15 19:50:45 EDT 2005


The first part is easy. I will have to think about the second part. To
find an opened copy of Word and switch focus to it do the following:

from win32com.client import Dispatch
word = Dispatch('Word.Application')
wdWindowStateNormal = 0
if len(word.Documents):
  word.Activate()
  if word.WindowState != wdWindowStateNormal:
    word.WindowState = wdWindowStateNormal  
 
-----Original Message-----
From: python-list-bounces+chad.hughes=pnl.gov at python.org
[mailto:python-list-bounces+chad.hughes=pnl.gov at python.org] On Behalf Of
John Henry
Sent: Wednesday, June 15, 2005 3:21 PM
To: python-list at python.org
Subject: Finding Word and switch focus to it


Does anybody know how to find an opened copy of Word and switch focus to
it, wait until Word is closed, before continuing my Python script? I
tried to search for the answer from Google and nothing stands out.

Running under Windows XP.

Thanks,

--
John

-- 
http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list