Unlock VBA Project

Posted on 2003-03-09
Medium Priority
Last Modified: 2008-02-01
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
Question by:tony_813
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 13

Accepted Solution

cri earned 1400 total points
ID: 8098155
Sorry, you can not.
LVL 13

Expert Comment

ID: 8098160
LVL 13

Expert Comment

ID: 8098168
Indirect confirmation: http://www.cpearson.com/excel/vbe.htm

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


Author Comment

ID: 8098187
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

Author Comment

ID: 8098191
Thank You!!!!
LVL 13

Expert Comment

ID: 8098491
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.
LVL 50

Expert Comment

by:Dave Brett
ID: 8100988
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.



Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question