• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

Unlock VBA Project

Hello Everyone,
   I have setup A Workbook with A Form...
   I have it where... when one clicks on a button... the form shows up..... etc...

   Now when they press the button...
   It also checks the current date... and I have an expiration date on it...

   I have placed this code to run... if the expiration date = the current date...

Sub DeleteAllVBA()
Dim VBComp As VBIDE.VbComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ActiveWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
    Select Case VBComp.Type
        Case vbext_ct_StdModule, vbext_ct_MSForm, vbext_ct_classModule
        VBComps.Remove VBComp
        Case Else
            With VBComp.CodeModule
                .DeleteLines 1, .CountOfLines
            End With
    End Select
Next VBComp


End Sub

  The problem.. is... that this code wont run... since I have protected my project with a password...
  I want a code... that will unprotect the project before running this code.. like this... it will
  run without a problem....


  Say the password   is XXXXX

Thank You
Tony_813
0
tony_813
Asked:
tony_813
  • 4
  • 2
1 Solution
 
criCommented:
Sorry, you can not.
0
 
criCommented:
0
 
criCommented:
Indirect confirmation: http://www.cpearson.com/excel/vbe.htm
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
tony_813Author Commented:
Hello Cri
  Darn Not what I wanted to hear....     (c:

However, I accept your response... also... that code... you see above.... thnx to you... on a recent posting.. gave me that idea as you had provided the link to someone else... thank you........

I appricate your quick response....

and even though it was a can't do response.. i'll raise it to 350... due to the fact.. I would have been here trying for ever... not knowing.. I was hitting a dead end..

thnx again
Tony_813
0
 
tony_813Author Commented:
Thank You!!!!
0
 
criCommented:
Thank you for not shooting the messenger.

As for your copy protection. This would require you hardcoding the password. In Excel 97 this string is visible for any viewer, despite locking the VBA project. The file is only encrypted when you use the file open protection password. Microsoft... Can not say if the newer versions fixed this.

Even if you could delete the modules: This protection would be as good as the 'Locked' property of the VBA project, which does not deter any power user nor people knowing how to use a search engine. A good VBA password cracker costs nothing to 30$, depending on the Excel version it was made with.

Consider putting as much of the number crunching/logic into a DLL or a COM. IMO you should be able to delete this file w/o trouble beyond the expiration date (did not test it though, some operating systems might protest). And, besides being faster, it offers the best protection against reverse engineering.
0
 
Dave BrettVice President - Business EvaluationCommented:
Hi Toni

I tried using the Sendkeys method to unlock a project a while back. No luck then but this has rekindled my interest, I'll let you know if I find it

BTW, its good to see a post where the answer is "no" get accepted.

Cheers

Dave
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now