#!C:\Perl\bin/perl.exe # -----------------------------------* use strict; use File::DosGlob 'glob'; use Win32::OLE qw(in with); use Win32::OLE::Const; use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; # Die on Errors. # -----------------------------------* # Main Program * # -----------------------------------* my $count = 0; my @xfiles = (glob "c:\\temp\\*.xls"); my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $Excel->{DisplayAlerts} = 0; foreach my $xname (@xfiles) { my $suf = $count++ . ".csv"; (my $savename = $xname) =~ s/xls/$suf/; my $Book = $Excel->Workbooks->Open($xname); foreach my $Sheet (in $Book->Sheets) { $Sheet->SaveAs($savename, xlCSV); } $Book->Close; } $Excel->{DisplayAlerts} = 1; # print "Press any key to quit."; until () {}