xlText is a CONSTANT (which has the value -4158 ) so you don't quote it as this makes it a string. You also need to disable DisplayAlerts or you will get prompted with the usual are you sure BS.
use Win32::OLE::Const; use Win32::OLE::Const 'Microsoft Excel'; my $Excel = Win32::OLE->new("Excel.Application" , sub { $_[0]->Quit } +) or die Win32::OLE::LastError; $Excel->{Visible} = 1; my $Book = $Excel->Workbooks->Open("c:\\test.xls") or die Win32::OLE::LastError; my $Sheet = $Book->Worksheets(1); $Excel->{DisplayAlerts} = 0; # avoid being prompted $Sheet->SaveAs( { FileName => "c:\\test.txt" , FileFormat => xlText } +) or die Win32::OLE::LastError; $Book->Close(); $Excel->Quit;
cheers
tachyon
In reply to Re: How to save a text file from excel
by tachyon
in thread How to save a text file from excel
by lori0825
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |