from Tkinter import Tkfrom time import sleepfrom tkMessageBox import showwarningimport win32com.client as win32warn = lambda app: showwarning(app, 'Exit?')RANGE = range(3, 8)def word(): app = 'Word' word = win32.gencache.EnsureDispatch('%s.Application' % app) doc = word.Documents.Add() word.Visible = True sleep(1) rng = doc.Range(0,0) rng.InsertAfter('Python-to-%s Testrnrn' % app) sleep(1) for i in RANGE: rng.InsertAfter('Line %drn' % i) sleep(1) rng.InsertAfter("rnTh-th-th-that's all folks!rn") warn(app) doc.Close(False) word.Application.Quit()Tk().withdraw()word()
Name (required)
email (will not be published) (required)
Website