List Info

Thread: Reading properties from office builtin dialogs?




Reading properties from office builtin dialogs?
user name
2006-01-31 09:32:59
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:pythonenvenv11libsite-packageswin32comclient
__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

_______________________________________________
Python-win32 mailing list
Python-win32python.org

http://mail.python.org/mailman/listinfo/python-win32
Reading properties from office builtin dialogs?
user name
2006-01-31 14:36:40
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:pythonenvenv11libsite-packageswin32comclient
__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'
>   
Odd - when I tried this win32com.client.constants did not
have an 
attribute wdDialogFilePrint. When I substituted 88 then I
got the 
printer dialog, and p.Printer returned my printer name!

Have you run makepy on word.application? If so note that
attributes are 
case sensitive. Did you try p.printer?
_______________________________________________
Python-win32 mailing list
Python-win32python.org

http://mail.python.org/mailman/listinfo/python-win32
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )