in reply to Problem opening WriteExcel generated spreadsheets with OLE

The problem has nothing to do with how the spreadsheet is generated. When using your code
use strict; use warnings; use 5.010; #use Spreadsheet::WriteExcel; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn=3; my $Excel=Win32::OLE->GetActiveObject('Excel.Application')|| Win32::OLE->new('Excel.Application', 'Quit'); my $book=$Excel->Workbooks->Open("./test.xls"); my $sheet=$book->Worksheets(1);
I get the same error on a spreadsheet I created myself with Excel 2003. Using the slightly modified code
use strict; use warnings; use 5.010; #use Spreadsheet::WriteExcel; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; $Win32::OLE::Warn=3; my $Excel=Win32::OLE->GetActiveObject('Excel.Application')|| Win32::OLE->new('Excel.Application', 'Quit'); my $book=$Excel->Workbooks->Open("c:\\data\\temp\\test.xls"); my $sheet=$book->Worksheets(1);
it opens the workbook just fine.

Replies are listed 'Best First'.
Re^2: Problem opening WriteExcel generated spreadsheets with OLE
by vassago (Novice) on Mar 03, 2010 at 21:50 UTC
    Well, crap, that works. The weird thing is, with the same exact code in the same folder, it would open one Excel file with the './' path, but not the others. Oh well. Thanks for clearing that up for me!

      Context, young one! Context!

      Internally, on Win32 (<==a context), Perl sees './test.xls', "./test.xls", '.\test.xls', and ".\\test.xls" as the same thing. But if you pass a pathname to something else (oh, say, part of the Windows API known as OLE, another context...), you need to make sure that thing will understand what you mean.

      To the Windows API, OLE, MS-Office, etc and so forth, "./test.xls" has no meaning.

      Capiche?