Question : Translate from Excel VBA to Perl the method "ProtectForSharing"

Hey guys!

I have an excel file un-protected "Un-Protected and un-shared workbook"

What I need to do is protect it ("Protected and shared workbook") during execution time. I am using Win32::OLE.

I am able to unprotect "Protected and shared workbook". But I can't protect it.

To be more clear:

I need to translate from Excel VB code to Perl the method "ProtectForSharing"

Workbooks(1).ProtectForSharing Password:="drowssap", _
SharingPassword:="gnirahs"  



Here is the code:


use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
 $Win32::OLE::Warn = 3;

 $| = 1;  
 
   
 my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
 || Win32::OLE->new('Excel.Application', 'Quit');

 $Excel->{Visible} = 1;
 my $Book = $Excel->Workbooks->Open("file.xls");
 my $Sheet = $Book->Worksheets(2);

 
 $Book->UnprotectSharing("password");  # It works very good

# The next expression doesn't work:
 
 $Book->ProtectForSharing({SharingPassword => "password"});
 
 $Book->Save;    
 $Book->Close;


  Thanks !
   

Answer : Translate from Excel VBA to Perl the method "ProtectForSharing"

For the above, a messagebox will popup for which u have to say "Yes" always.
Random Solutions  
 
programming4us programming4us