[python-win32] Printing a Word file silently

Tim Golden tim.golden at viacom-outdoor.co.uk
Wed Dec 24 04:12:15 EST 2003


>From: Alexandre Lemière [mailto:alexandre.lemiere at laposte.net]
>
>from win32com.client import constants,Dispatch,DispatchEx
>WORD = 'Word.Application.8'
>Faux, Vrai = 0,1
>
>class Word:
>    def __init__(self):
>        self.app = DispatchEx(WORD)
>        #self.app.Visible = 1
>    def ouvrir(self, doc):
>        self.app.Documents.Open(FileName=doc)
>    def imprimer(self):
>        self.app.Application.ActivePrinter = "PostScript"
>        
>self.app.Application.PrintOut(OutputFileName=r"c:\temp\testout.
>ps", PrintToFile=1, Append=Faux)
>    def quitter(self):
>        self.app.Documents(r"c:\temp\test.doc").Close(SaveChanges=Faux)
>)
>
>if __name__ == '__main__':
>    word = Word()
>    word.ouvrir(r"c:\temp\test.doc")
>    word.imprimer()
>    word.quitter()  
>

This may be of no use to you at all, but running your code (with a stray
 right bracket removed) on my Win2k box with Word2000 works perfectly.
 In fact, this is Word.Application.9 masquerading as Word.Application.8, 
 so it may be that Word97 (aka Word 8) doesn't behave exactly the same.

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-win32 mailing list