Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101731 > unrolled thread

Python and Word OLE

Started bytdsperth@gmail.com
First post2016-01-14 22:03 -0800
Last post2016-01-18 15:53 -0800
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Python and Word OLE tdsperth@gmail.com - 2016-01-14 22:03 -0800
    Re: Python and Word OLE Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-15 08:02 -0500
    Re: Python and Word OLE tdsperth@gmail.com - 2016-01-18 15:53 -0800

#101731 — Python and Word OLE

Fromtdsperth@gmail.com
Date2016-01-14 22:03 -0800
SubjectPython and Word OLE
Message-ID<d46c8767-f485-4589-8850-6e9fa372a3e9@googlegroups.com>
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

[toc] | [next] | [standalone]


#101750

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2016-01-15 08:02 -0500
Message-ID<mailman.10.1452862959.15297.python-list@python.org>
In reply to#101731
On Thu, 14 Jan 2016 22:03:37 -0800 (PST), tdsperth@gmail.com declaimed the
following:

>
>wordapp = win32com.client.Dispatch('Word.Application')
>worddoc = wordapp.Documents.Open(mypathfile)
>print(wordapp.ActivePrinter)
>"\\server\queries"
>wordapp.ActivePrinter = "\\server\letters" //fails on this line
>

	Which version of Python?

PythonWin 2.7.5 (default, Sep 16 2013, 23:11:01) [MSC v.1500 64 bit
(AMD64)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for
further copyright information.
>>> print "\\server\letters"
\server\letters
>>> 

>>> print r"\\server\letters"
\\server\letters
>>> 

	Note the difference?
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#101888

Fromtdsperth@gmail.com
Date2016-01-18 15:53 -0800
Message-ID<e3e130e9-f994-4f56-b55f-dc003f5eb1b8@googlegroups.com>
In reply to#101731
On Friday, January 15, 2016 at 2:04:08 PM UTC+8, tdsp...@gmail.com wrote:
> 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

\\\\server\\letters - the extra back slashes were required.

Colin

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web