in reply to Unprotect source code from Excel files with perl

Win32::GuiTest provides SendKeys (inspired by Win32::OLE Outlook and E-mail security update)
  • Comment on Re: Unprotect source code from Excel files with perl

Replies are listed 'Best First'.
Re^2: Unprotect source code from Excel files with perl
by Echoes (Initiate) on Oct 14, 2008 at 12:01 UTC
    Hi, I finally found a solution to my problem. This is what I do:
    use Win32::OLE qw(in with); ... $Excel = Win32::OLE->new('Excel.Application', 'Quit'); $Excel->{Visible} = $vttrue; $oBook = $Excel->Workbooks->Open("wishyouwerehere.xls"); ... if ($oBook->VBProject->{Protection} == 1) { $Excel->VBE->CommandBars->FindControl({ID=>2578})->Execute; $Excel->SendKeys ($pass); $Excel->SendKeys ("{ENTER}"); $Excel->SendKeys ("{ESC}"); sleep(1); } ...
    What is very important here and make things work is sleep(1). It gives time to enter the password and unprotect the project which is the key for the rest of my program. Thanks for your help :) Regards.