in reply to Re^7: Reading Excel
in thread Reading Excel

my data starts from B1.If i am running the below script it is showing can't call method worksheets o an undefined value.

use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; my $Excel=Win32::OLE->GetActiveObject('Excel.Application') $excelfile= "C:/perlpractice/simple.xlsm"; $Book=$Excel->Workbooks->Open($excelfile); $Sheet=$Book->Worksheets(1);

Replies are listed 'Best First'.
Re^9: Reading Excel
by huck (Prior) on Jan 30, 2017 at 06:26 UTC

    After fixing your bugs this works for me

    use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn = 3; #my $Excel=Win32::OLE->GetActiveObject('Excel.Application') my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); #$excelfile= "C:/perlpractice/simple.xlsm"; $excelfile= "C:/perlpractice/testfile.xlsm"; $Book=$Excel->Workbooks->Open($excelfile); $Sheet=$Book->Worksheets(1);

      Thankyou.But if iam running the same script OLE exception fro m "Microsoft Excel"; Unable to get the Open property of the Workbook class.Win32::OLE (0.1709)error 0x800a03ec in METHOD/PROPERTYGET "Open" at C:\Perl\Read.pl

        i got that message when i had only

        my $Excel=Win32::OLE->GetActiveObject('Excel.Application');
        instead of
        my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit');
        Do you reaize what the difference is?