Hi,

I am a newbie to python. I was trying to import an execl application to python. To startwith i'm trying to open a excel file using python script.

In some of the sample scripts that are available on internet has the following contents.
--------------------------------------------------------------------------------
import win32API.client
import pythoncom
app = win32API.client.Dispatch('Excel.Application')
app.Visible = 1
app.Quit()
print pythoncom._GetInterfaceCount()
app = None
print pythoncom._GetInterfaceCount()
pythoncom.CoUninitialize()
------------------------------------------------------------------------------

When i run this script on python2.5 that i had installed on my machine, it reports the error message as follows.
Traceback (most recent call last):
File "C:\Python25\xl.py", line 12, in <module>
import win32API.client
ImportError: No module named win32API.client

Can anyone help me to fix this? What is win32com.client? Do i have to install anything specifically along with python2.5?

It would be very helpful if anyone can guide me on this.

Thanks in advance,
goms

import win32API.client
ImportError: No module named win32API.client

I use Linux, but I think you would want to import win32API, without '.client' although I'm not sure. If that fails, search for win32API on you system. It is likely that you have to append the path to PYTHONPATH using sys.path.append( some_path_name).
EDIT: Thinking that this has to have been done already, I found this link
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/483742
This routine also requires xlrd, and the author gives a download link in the comments at the top. Python is great. There are code snippets that do so many things.

You need to download and install the Python Extensions for Windows:
pywin32-210.win32-py2.5.exe
free from:
http://sourceforge.net/projects/pywin32/

This is a self-installing exe file, so all you need to do is doubclick the filename.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.