Ed Blake schrieb:
> Yay, more problems!  Today i need to set a property of a specific object,
> unfortunately I can't get the object because instead I am given a pointer to
> a bound method.  I've poked around as much as I could, but I can't figure
> this one out either.
> 
> The object is accessed thus:
> Application.ActiveSettings.TextStyle
> Application.ActiveSettings returns a pointer to an _Settings object
> Here is the _Settings._methods_ entry for the property I want to access:
> COMMETHOD([dispid(1610743823), 'propget'], HRESULT, 'TextStyle',
>           ( ['retval', 'out'], POINTER(POINTER(_TextStyle)), 'pVal' )),
> 
> Here is the output and the error thrown:
> <bound method POINTER(_Settings).TextStyle of <POINTER(_Settings) object
> 2e2ec60>>
> Traceback (most recent call last):
>   File "G:\files\scripts\table.py", line 109, in <module>
>     build_table(app, excel)
>   File "G:\files\scripts\table.py", line 58, in build_table
>     old_just = style.Justification
> AttributeError: 'WinFunctionType' object has no attribute 'Justification'
> 
> I'm trying to retrieve the object, but the property can also be set to a new
> object if that matters.

I'm convinced that properties work in principle.  This example code demonstrates
setting properties with MS Word:

import comtypes.client

word = comtypes.client.CreateObject("Word.Application")
        
word.Visible = 1

doc = word.Documents.Add()
wrange = doc.Range()
for i in range(10):
    wrange.InsertAfter("Hello from comtypes %d\n" % i)

for i, para in enumerate(doc.Paragraphs):
            para.Range.Font.ColorIndex = i+1
            para.Range.Font.Size = 12 + (2 * i)
            para.Range.Font.Shading.Texture = -12


What COM object are you using?  Is it possible for me to install it?
Or can you try to reproduce this bug also with other objects?

> Ed Blake
> 
> PS: I haven't gotten around to dissecting the latest comtypes sources yet. 
> I'm not sure I've really gotten ConnectionPoints or whatever yet anyway.  I
> have something I'd rather be working on, but if I have to spend too much time
> on COM I will probably have a look.

Thomas


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to