Windows Perl Scripting Forums » Scripts

win32::ole unable to open excel workbook

(2 posts)

No tags yet.


  1. Anonymous

    Hello All,

    I m using the following to open and close excel files and access sheets.
    my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
    || Win32::OLE->new('Excel.Application', 'Quit');

    # turn off all the alert boxes
    $Excel->{DisplayAlerts}=0;

    my $book=$Excel->Workbooks->Add();
    $book->SaveAs("C:\\dropbox\\test.xls");
    my $sheet=$book->Worksheets("Sheet1");
    $sheet->Activate();
    $book->Save();
    $book->Close;

    $book=$Excel->Workbooks->Open("C:\\dropbox\\test.xls");
    $sheet=$book->Worksheets("Sheet2");
    $sheet->Activate();
    $book->Save();
    $book->Close;

    This works fine on excel 2007. However, on excel 2010 it seems to not be able to open the file second time and errors out with the following message:
    Can't call method "Worksheets" on an undefined value at ...

    Any ideas why excel can be re-opened after closing on excel 2010?
    Appreciate your help.
    Thanks

    Posted 6 years ago #
  2. Anonymous

    I read all the codes and it seems right, so i think maybe this is cause any other mistake by the way i will search for it and try to find any legit solution bout this.

    __________________
    ebook reader

    Posted 6 years ago #

RSS feed for this topic

Reply

You must log in to post.