Python and Word OLE
tdsperth at gmail.com
tdsperth at gmail.com
Fri Jan 15 01:03:37 EST 2016
Hi All
I am trying to change the active printer using win32com.client with the following code
wordapp = win32com.client.Dispatch('Word.Application')
worddoc = wordapp.Documents.Open(mypathfile)
print(wordapp.ActivePrinter)
"\\server\queries"
wordapp.ActivePrinter = "\\server\letters" //fails on this line
File "C:\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 544, in __setattr__
self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Word', 'There is a printer error.', 'wdmain11.
chm', 24696, -2146823072), None)
If I don't try to change printers - it prints too the default printer.
Cheers
Colin
More information about the Python-list
mailing list