Default location while open an Excel file

Johnny johnnylee194 at
Fri Oct 20 05:08:38 CEST 2006

   As you know, I can use this to open an Excel file:
import win32com.client

doc = win32com.client.Dispatch("Excel.Application")
doc.Workbooks.Open(excelFile, ReadOnly=True)

   But the problem is when I only pass the filename to the Open()
method, and of course the file is in the current directory, it will
throw an exception that the specified file can't be found. When I use
os.path.abspath(excelFile) instead, it works. But I do know that
somebody can only pass a filename, and no exception is raised. Now I
wonder is that because the "somebody" happen to put the file on the
default location of the Open() method? If so, does any one know the
default location?

   Thanks for your consideration.


More information about the Python-list mailing list