in reply to Problem using SaveAs when trying to change Excel format

xlOpenXMLWorkb is supposed to be a number (read microsoft constant), not the string 'xlOpenXMLWorkb'
  • Comment on Re: Problem using SaveAs when trying to change Excel format

Replies are listed 'Best First'.
Re^2: Problem using SaveAs when trying to change Excel format
by JRBJhawk (Novice) on Nov 10, 2009 at 16:35 UTC

    Thanks. That fixed it

      Hi, I' new to perl. I'm appending a row in the excel file. But a pop comes out(to save the temp file) while saving a file. Below is the code I'm using to do the same.

      my $Excel = Win32::OLE->GetActiveObject('Excel.Application') | +| Win32::OLE->new('Excel.Application'); $Excel->{'Visible'} = 0; #0 is hidden, 1 is visible $Excel->{DisplayAlerts}=0; #0 is hide alerts # Open File and Worksheet util->logit("[$PARENT_PROC_NAME]: in_file[$in_file]"); my $Book = $Excel->Workbooks->Open($in_file); # open Excel file my $sheetcount = $Book->Worksheets->Count; #util->logit("[$PARENT_PROC_NAME]: sheetcount[$sheetcount]"); foreach my $i (1 .. $sheetcount) { #util->logit("[$PARENT_PROC_NAME]: i value [$i]"); my $Sheet = $Book->Worksheets($i); if(defined($Sheet)) { util->logit("[$PARENT_PROC_NAME]: Sheet[$Sheet]"); my $LastRow = $Sheet->UsedRange->Row + $Sheet->UsedRange-> +Rows->Count - 1; util->logit("[$PARENT_PROC_NAME]: LastRow[$LastRow]"); $Sheet->Cells($LastRow+1,1)->{Value} = localtime; } } #$Book->SaveAs(Filename =>$in_file); #my $file_ointer = $Book->Save(); #$Book->SaveAs(); $Book->SaveAs(); $Book->Close(); $Book->Quit(); undef $Book;

      I need to save the changes without any manual efforts... Kindly suggest something. Thanks in advance.

        Why don't you try giving SaveAs parameters exactly like in the OP?