[python-win32] Reading properties from office builtin dialogs?

Anders Quist quest at strakt.com
Tue Jan 31 10:32:59 CET 2006


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



More information about the Python-win32 mailing list