You are only looking after xls files
for each Ext in 'xls'
Extend your for-loop to this:
for each Ext in 'xls', 'csv'
I notice you are declaring a variable delimet, let delimet= if(Ext='xls','biff, embedded labels, table is Sheet1$',if(Ext='csv','txt, codepage is 1252, embedded labels, delimiter is ',', msq');,but you are not using it.
Try someting like this:
FROM [$(File)] ($(delimet)) ;
make sure that the load statement works for a single xls-file using your Load statement? My guess is that your 'embedded labels' will give you trouble hence you are writing @1, @2 etc.
Try something like this. Note that the 'xls' will return both xls and xlsx files. You attaced an xlsx-file which is not read as biff but ooxml.
sub DoDir1 (Root) for each Ext in 'xls', 'csv' for each File in filelist (Root&'*.' &Ext) let vL.FileExtension = SubField('$(File)', '.', -1) ; //filelist(*.xls) returns both xlsx and xls switch vL.FileExtension CASE 'xlsx' //XLSX are ooxml format set delimet=(ooxml, embedded labels, table is Sheet1); CASE 'xls' //XLS is biff format set delimet=(biff, no labels, table is Sheet1$); CASE 'csv' set delimet=(txt, codepage is 1252, embedded labels, delimiter is ',', msq); ENDSWITCH gateway: Load Date, Time, Machine, code, Text, ID, Name, Department, FileName() as test FROM [$(File)] $(delimet); ; next File next Ext end sub call DoDir1 ('.\')