in reply to Problems opening an Excel file...


There are probably a lot of things that can cause this error but one of them is the case where the input file cannot be found. This is turn may be caused by the fact that Excel searches in the user's "My Documents" directory for the file to open and not in the directory that the script is run from.

If you aren't already doing so, specify the path to the file in Open() to see if it fixes the problem.

--
John.

Replies are listed 'Best First'.
Re^2: Problems opening an Excel file...
by olivierp (Hermit) on Feb 10, 2005 at 11:33 UTC
    To complement lmcmanamra's point, 2 other things that can cause this are "/" in the path instead of "\", and opening twice the same file name.
    HTH
    --
    Olivier
      Thanks for your comments. Unfortunately, after some double-checking, none of these seem to be the problem. Here's what the command line looks like:
      c:\perl\bin\perl.exe c:\perl\excel\TestRead.pl "c:\test.xls"
      When I run this from the command line, it works perfectly. When I call it from SQL Server, it fails with the above error.
      I'm especially weirded out by the fact that I'm not getting an error description. That or the description is a series of 4 spaces, which is the crappiest description ever. I blame Microsoft.
        c:\perl\excel\TestRead.pl "c:\test.xls"
        Wild guess. Could \t be perchance translated to a tab, leading your script to open c:\   est.xls
        Try  my $file = "c:\test.xls" in your snippet, and you should get something like this:
        P:\>c:\temp\openxl.pl "c:\temp\test.xls" OLE exception from "Microsoft Office Excel": 'c: emp est.xls' could not be found. Check the spelling of the + file name, and verify that the file location is correct. If you are trying to open the file from your list of most recently use +d files on the File menu, make sure that the file has not been renamed, +moved, or deleted. Win32::OLE(0.1702) error 0x800a03ec in METHOD/PROPERTYGET "Open" at c:\temp\openxl.pl line 10
        HTH
        --
        Olivier