Have you ever seen this:

=========================================================
OLE exception from "Microsoft Excel":

Unable to get the SaveAs property of the Workbook class

Win32::OLE(0.15) error 0x800a03ec
    in METHOD/PROPERTYGET "SaveAs"
=========================================================

The following code is working fine, but I recently received a file damaged
by virus infection and something strange happens. I'm sure the file can be
opened and saved as xlText in Excel manually - I've tested it manytimes. I'm
sure the file is opened by my code (I can read the values in the file), but
I'm UNABLE to save the file.

I've tested both types of invoking SaveAs method

    $book->Invoke('SaveAs', { Filename => File::Spec->rel2abs("temp.txt"),
FileFormat => xlText, CreateBackup => 0 });
    $book->SaveAs( { Filename => File::Spec->rel2abs("temp.txt"), FileFormat
=> xlText, CreateBackup => 0 });

both are working fine, but only with files that didn't get touched with
virus.

The files was successfully cured by NAV2001 (latest virus database) the
virus name "X97M.Jini.A1".

Workaround: open damaged file in Excel, select all, create new file, paste
and use the new file.
DO YOU KNOW ANOTHER SOLUTION HOW TO HANDLE FILES CURED AFTER VIRUS ATTACK?

use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
use File::Spec;

    $excel = Win32::OLE->new('Excel.Application', 'Quit')
    or die "Oops, cannot start Excel";
    $excel->{Visible} = 1;

    $book = $excel->Workbooks->Open({
      UpdateLinks => 0,
      FileName => File::Spec->rel2abs( 'LW.Gea.LPP.xls' ),
      ReadOnly => 1 });

    print ( Win32::OLE::LastError() ) if Win32::OLE::LastError();

    $book->Invoke('SaveAs', { Filename => File::Spec->rel2abs("temp.txt"),
FileFormat => xlText, CreateBackup => 0 });

    print "--------------------\n";
    print (Win32::OLE::LastError() ) if Win32::OLE::LastError();
    print "\n--------------------\n";

    $book->Close({ SaveChanges => 0 });
    print ( Win32::OLE::LastError() ) if Win32::OLE::LastError();


-- Petr Smejkal

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to