win32com.client - missing methods?

chaluba at yahoo.com chaluba at yahoo.com
Thu Feb 22 12:11:57 EST 2001


I ran into the same problem below, the first day I tried using
win32com on NT. I eventually fixed it and the following is my account
hoping it helps you or others.

Setup (work): WinNT4.0SP6a + python1.52 + win32all-136 + MS Office 97

BuiltInDocumentProperties is a DocumentProperties object defined in
MS Office type library. I had generated type libraries for MS Office,
and DocumentProperties did not seem to have any methods. However, when
I browsed with COM Browser, I was able to see its methods.

Setup1 (home): Win2K + python1.52 + win32all-136 + MS Word 2000
Setup2 (home): Win2K + ActivePython 2.02 + MS Word 2000

At home I tried to access methods of BuiltInDocumentProperties and it
worked under both setups. I had not generated any type libraries
manually assuming they'd be auto-generated. They were not generated.

Back to work, I deleted the type libraries and voila - it worked. Type
libaries were not generated. I'm not sure if it's supposed to work
like that but it sure confused me quite a bit (the fact that it did
not work with generated type libraries). 

Maybe someone can comment.

Ayhan

--- In python-list at y..., "Kirby James" <kirby at j...> wrote:
> Hi, I've written a Python program which uses the win32com interface
to
> obtain information from a number of Word-97 files.
> The program runs fine on my Win-98 system but fails on two NT
systems.
> The problem line is :-
> 
>     sAuthor =
myDoc.BuiltInDocumentProperties(constants.wdPropertyAuthor)
> 
> which produces the error
> 
>     AttributeError: no __call__ method defined
> 
> When I remove this line the other COM functions that I call work
fine. On
> all three systems I've run the COM Makepy utility - but I notice
that
> the generated files are of different sizes on the different systems
(is it
> safe to copy - and rename the win-98 file to NT).
> 
> I'd appreciate any pointers
> 
> ta, Kirby
> 
> 
> Traceback (most recent call last):
>   File "D:\Python20\Pythonwin\pywin\framework\scriptutils.py", line
301, in
> RunScript
>     exec codeObject in __main__.__dict__
>   File "D:\python\utilities\word2.py", line 178, in ?
>     os.path.walk('d:\\relocation', walker, 10)
>   File "D:\Python20\lib\ntpath.py", line 270, in walk
>     walk(name, func, arg)
>   File "D:\Python20\lib\ntpath.py", line 264, in walk
>     func(arg, top, names)
>   File "D:\python\utilities\word2.py", line 153, in walker
>     readWord(pathfilename)
>   File "D:\python\utilities\word2.py", line 64, in readWord
>     sAuthor =
myDoc.BuiltInDocumentProperties(constants.wdPropertyAuthor)
> AttributeError: no __call__ method defined
> 
> 
>     WORD  = 'Word.Application.8'
> 
>     myWord = Dispatch(WORD)
>     myWord.Visible = 1
>     myDoc = myWord.Documents.Open(fn)
>     sAuthor =
myDoc.BuiltInDocumentProperties(constants.wdPropertyAuthor)
> ####  line 64
>     sAuthor = str(sAuthor)
>     print '  Author = ' + sAuthor
> 
> 
> 
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list