Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Perl to access Excel File

Status
Not open for further replies.

chicateer

Technical User
Nov 24, 2003
4
GB
I am trying to read an Excel file that has a password. When I use the Workbooks->Open(filename,,,,password,) statement, i get an error ""unable to get the Open property of the Workbooks class"

any help would be appreciated

thanks
 
This would seem to be a problem with the spreadsheet not wanting to open to unauthorised users

Code would help, of course, obfuscate usernames and password details

--Paul
 
Paul, thanks for your response.
I enclose a sample version of the code that keeps failing
Appreciate any help that you can give on this one.

thanks,

use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
$test = 0;
$filename = 'c:\test.xls';
$ps = 'xx';
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')|| Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->Open($filename,,,,$ps);
$k = $Excel->Workbooks->Count;
print "$k\n";
 
Does it fail on ALL workbooks or just this particular workbook?

If you want ot use Excel::WorkBook over the ActiveX objects it may bypass windows security features and do what you need it to :)

 
yes, it fails on all workbooks - Did not quite understand your comment of using the Excel::Workbook over ActiveX objects. Would appreciate some further details

thanks
 
You may or may not have noticed that using
"my $Book = $Excel->Workbooks->Open($filename);"
apparently works fine.

Where do you find a list of the functions to be called on the OLE objects and their syntax? I suppose this can't be found with perldoc.

Greetings,
Swamphen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top