Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Introspection of win32com module / pythoncom module

Tags:

python

what is the best way to see what all functions that can be performed using pythoncom module? Specifically, i was working with the win32com module to operate upon excel files. I was not able to find introspection for it as we do for the rest of the modules. Can anyone please suggest how can i retrieve this information?

like image 486
crystal Avatar asked Mar 04 '10 14:03

crystal


1 Answers

run the make.py file in \lib\site-packages\win32com\client.

When you run it, a dialog comes up showing installed COM objects... choose the one for the Excel Ojbect library and you'll get something like this:

c:\Python26\Lib\site-packages\win32com\client>makepy.py
Generating to C:\Python26\lib\site-packages\win32com\gen_py\00020813-0000-0000-C
000-000000000046x9x1x0.py
Building definitions from type library...
Generating...
Importing module

Now when you call win32com.client.Dispatch on Excel, the object you get back will have attributes that support introspection (from the file that gets created when you run the step above). This is basically creating an early-bound version of the COM object.

This topic is covered in detail in Mark Hammond's "Python Programming on Win32". It's an old book, but still very useful! http://www.amazon.com/Python-Programming-WIN32-Windows-Programmers/dp/1565926218

like image 121
cprinos Avatar answered Sep 18 '22 00:09

cprinos