Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unlock VBA Project after getting wrong first time
I need to be able to unlock the VBA Project within my code. I have
used the following code that I found on the net Private Sub UnprotectVBProject(WB As Workbook, ByVal Password As String) Dim vbProj As VBIDE.VBProject Set vbProj = WB.VBProject 'can't do it if already unlocked! If vbProj.Protection < 1 Then Exit Sub Set Application.VBE.ActiveVBProject = vbProj ' now use lovely SendKeys to quote the project password SendKeys Password & "~~" Application.VBE.CommandBars(1).FindControl(ID:=257 8, recursive:=True).Execute SendKeys "{ESC}" DoEvents End Sub This code works fine when used first time. The problem is, if the user types the wrong password in, then I call the same routine, it leaves the Project Properties form on the screen, although it has correctly unlocked the project. Can someone please help? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is there a way to unlock a project in VBA if you know the password | Excel Programming | |||
Unlock VBA project | Excel Discussion (Misc queries) | |||
Unlock VBA Project | Excel Programming | |||
Unlock VBA Project | Excel Discussion (Misc queries) | |||
Unlock VBA project | Excel Programming |