I am trying to open password protected excel and save it with no password. I know the password. When I am trying to run the code below, the file is being saved with the password.
#!/usr/bin/perl
use strict;
use warnings,
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel *';
my $file = "in.xls";
my $outFile = "out.xls";
my $Excel = Win32::OLE->new ('Excel.Application', 'Quit');
$Excel->{'Visible'} = 0; #0 is hidden, 1 is visible
$Excel->{'DisplayAlerts'} = 0; #0 is hide alerts
my $Book = $Excel->Workbooks->Open({FileName => "$file", Password => 'test'});
my $Sheet = $Book->Worksheets('test');
$Sheet->Activate();
$Book->SaveAs({Filename=>"$outFile",FileFormat=>xlWorkbookNormal});
$Excel->Quit();
Please advise.
Thank you, -Andrey
I figured out the answer:
$Book->SaveAs({Filename=>"$outFile",FileFormat=>xlWorkbookNormal, Password => undef});
Thanks guys.