I need help to open a password protected excel file in perl using Win32:OLE.
when I tried to open file in normal way at the time of program execution it is prompting me to enter password.
I am giving the script i used for opening excel file..
So i want to know how to provide password parameter while opening the file.
Expand|Select|Wrap|Line Numbers
- use strict;
- use Win32::OLE;
- use Win32::OLE::Const 'Microsoft Excel';
- use Win32::OLE::Variant qw(:DEFAULT nothing);
- $Win32::OLE::Warn = 3;
- my $excelObj;
- my $fileName = "D:\\Mohan\\test.xls";
- $excelObj = Win32::OLE->new('Excel.Application', 'Quit');
- $excelObj->{'DisplayAlerts'} = 0;
- $excelObj->{'AskToUpdateLinks'} = 0;
- $excelObj->{'Visible'} = 0;
- my $bookObj;
- # If there is any problem in accessing files then auto mail will be sent.
- eval
- {
- $bookObj = $excelObj->Workbooks->Open($fileName);
- };
- if($@)
- {
- my $msg = "";
- die "A problem was encountered when accessing the file $fileName \n";
- }
- my $sheetObj = $bookObj->Worksheets(1);
- my $val = $sheetObj->Cells(10,3)->{'Value'};
- print "Value == $val\n";
- $excelObj->ActiveWorkbook->Close(0);
- $excelObj->Quit();