Please tell me a solution to suppress passsword prompting of an excel file.
use Win32::OLE;
my $xlApp = Win32::OLE->new('Excel.Application');
$xlApp->{Visible} = 0;
$xlApp->{DisplayAlerts} = 0;
# Open excel file.
my $xlBook = $xlApp->Workbooks->Open("C:\\Documents and Settings\\username\\Desktop\\testfile.xls");
my $Sheet1 = $xlBook->Worksheets(1);
my $row = 1;
my $col = 1;
$Sheet1->Cells($row,$col)->{'Value'} = 5;
if (Win32::OLE->LastError)
{
print "File protected";
}
$xlBook ->Close();
undef $xlBook;
You may convert the following vb code to perl and give a try, Please note that this code is for vbproject, similary you can check for the worksheets, cells, or entire sheet, the same way.
' returns TRUE if the VB project in the active document is protected ' Please not
Example:
For Worksheet
For active work book windows
and so on..
Or You can open excel sheet with password
The Open method for the Workbook object, takes 12 arguments. To open a workbook with password protection, you would need to write the following code:
You can also check with perl the same with empty arguments. I am not sure how to give...
Working off of lakshmanaraj's idea, and unknown's response:
If you know the passwords, you can supply them in the password and/or writerespassword arguments of the open command. Excel will not prompt for the passwords if they are supplied this way.
If you don't know the passwords but want to prevent the dialog box from appearing, you can supply dummy passwords in these parameters ("ThisIsNotAPassword", for instance). I have not found this in the documentation, but tested it in Excel 2003: