Anders Quist wrote:
>I have an application that wants to print a large set of documents.
> Therefore, I want to have word display its print dialog so the user
> can supply printer settings once, that I can read and store for use
> with all following prints.
>
> At first glance, this would seem straight-forward; VBA like so:
>
>    Dim dlgPrint As Dialog
>    Set dlgPrint = Dialogs(wdDialogFilePrint)
>    dlgPrint.Display
>    MsgBox "printer = " & dlgPrint.Printer
>
> However, when tried in python, the property Printer does not seem to
> be available. A little trial-and-error indicates that no such
> properties are available from Word builtin dialogs:
>
>    >>> import win32com.client
>    >>> x = win32com.client.Dispatch("Word.Application")
>    >>> p = x.Dialogs(win32com.client.constants.wdDialogFilePrint)
>    >>> p.Display()
>    <dialogs displayed>
>    >>> p.Printer
>    Traceback (most recent call last):
>      File "<stdin>", line 1, in ?
>      File 
> "c:\python\env\env11\lib\site-packages\win32com\client\__init__.py", line 
> 451, in __getattr__
>        raise AttributeError, "'%s' object has no attribute '%s'" % 
> (repr(self), attr)
>    AttributeError: '<win32com.gen_py.Microsoft Word 10.0 Object 
> Library.Dialog instance at 0x21494960>' object has no attribute 'Printer'
>
> What am I doing wrong?
> --
> Anders Qvist, AB Strakt
>

Using early binding (makepy), the Printer property isn't available since 
it's not
defined in the typelib.  You can force a dynamic dispatch,
though:
 >>> dynamic_p=win32com.client.dynamic.DumbDispatch(p)
>>> dynamic_p.Printer
u'Lexmark 710 Series'

    hth
       Roger

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to