[python-win32] from excel to word
Tim Golden
mail at timgolden.me.uk
Fri Jul 25 17:26:54 CEST 2008
Emanuel Sotelo wrote:
> #word part
> wordapp = Dispatch("Word.Application")
> wordapp.Visible = 1
> worddoc = wordapp.Documents.Add()
> rango = worddoc.Range(0,0)
> rango.InsertBefore('hi we are goin to bring the data from excel and have
> it print in word')
> worddoc.SaveAs(MYDIR+ '\\wordexcel.doc')
> rango.InsertAfter(xl.Cells(3,6))
>
> #print part
> dc= win32ui.CreateDC()
> dc.CreatePrinterDC()
> # i dont now what else is supposed to go in this part to send it to print
Well, you don't need to mess with Device Contexts
in order to print from Word. As with most "How
do I do this in MS Office?" questions, the answer
is: record a macro which does what you want, and
then look at the resulting VBA code and reproduce
it in Python -- which is usually trivial.
TJG
More information about the python-win32
mailing list