in reply to Re: Question about Win32::OLE and Excel
in thread Question about Win32::OLE and Excel

I try it, but even the simple code below doesn't work and I dont understand why:
use strict; # Create Chart use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; my $Excel = Win32::OLE->new("Excel.Application"); $Excel->{Visible} = 1; #my $Book = $Excel->Workbooks->Add; my $Workbook = "Auswertung022004.xls"; my $activeWorkbook = $Excel->Workbooks->Open($Workbook); my $Sheet = $activeWorkbook->Worksheets("INF2");
The Error Message is:
Can't call method "Worksheets" on an undefined value at H:\work\Auswer +tungen\ExcelChartWrite.pl line 14.

I would try to activate a Worksheet, even if I replace "INF2" with 1 (which should be the first sheet) the same Error Message shows up, what did I wrong?

Even if I put the line out, the Excel File Closes imediatly, Because of that it would be much easier to simply put the macro into the Excel file, because the macro has been debuged and runns propperly

Replies are listed 'Best First'.
Re: Re: Re: Question about Win32::OLE and Excel
by Grygonos (Chaplain) on Apr 20, 2004 at 17:43 UTC

    might try using zero based counting instead of 1. Also, the file will try to be opened inside the same directory that the script is running from. If this is not your intent you should specify a path along with the filename


    Grygonos
      Also, the file will try to be opened inside the same directory that the script is running from. If this is not your intent you should specify a path along with the filename
      Good advice specifying the full path, but Excel doesn't care about your current working directory or where the script is located.

      Excel looks for the file in its "Default file location", usually My Documents. Check Tools->Options->General->"Default file location".