[Tutor] Looping, and Win32com.client

Tim Golden mail at timgolden.me.uk
Fri Dec 19 17:28:15 CET 2008


Tim Golden wrote:
> Eduardo Vieira wrote:
>> Hello, this is my first post in this list and I'm not a programmer,
>> but am enjoying learning python.
>> I'm trying to make a script to add worksheets to excel files:
>> I managed to implement this code:
>>
>> import os
>> folder = 'C:\\Personal\\oldxlsformat\\'
>> from win32com.client import Dispatch
>> xl = Dispatch('Excel.Application')
>> xl.Application.AskToUpdateLinks = "False"
>> for ficheiro in os.listdir(folder):
> 
> 
> os.listdir returns a list of files relative to
> the directory in question. (Try it at the
> interpreter and see). Excel requires, pretty
> much, a list of absolute filenames.

Of course, I meant this it requires one absolute
filename, not a list :)

TJG


More information about the Tutor mailing list