Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can project unprotect self?
Hi,
I'm using the following code (which I found in this news group) to have the project unprotect itself Sub UnprotectVBProject(ByVal Password As String) Dim vbProj As Object Set vbProj = ThisWorkbook.vbProject If vbProj.Protection < 1 Then Exit Sub Set Application.VBE.ActiveVBProject = vbProj SendKeys "MyPassword" & "~~" Application.VBE.CommandBars(1).FindControl(id:=257 8, recursive:=True).Execute End Sub but two bad things happen: 1. It prompts for the password anyway. 2. Whatever code follows the call to the sub does not wait for this sub to exit, but proceeds to execute and fails b/c the project is still protected. How can I solve each problem? Very many thanks in advance! Aaron Fude |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can project unprotect self?
Try this alternative
With Application .SendKeys "%{F11}", True ' VBE .SendKeys "^r", True ' Set focus to Explorer .SendKeys "{TAB}", True ' Tab to locked project .SendKeys "~", True ' Enter .SendKeys "password" .SendKeys "~", True ' Enter End With -- HTH Bob Phillips (remove xxx from email address if mailing direct) wrote in message ups.com... Hi, I'm using the following code (which I found in this news group) to have the project unprotect itself Sub UnprotectVBProject(ByVal Password As String) Dim vbProj As Object Set vbProj = ThisWorkbook.vbProject If vbProj.Protection < 1 Then Exit Sub Set Application.VBE.ActiveVBProject = vbProj SendKeys "MyPassword" & "~~" Application.VBE.CommandBars(1).FindControl(id:=257 8, recursive:=True).Execute End Sub but two bad things happen: 1. It prompts for the password anyway. 2. Whatever code follows the call to the sub does not wait for this sub to exit, but proceeds to execute and fails b/c the project is still protected. How can I solve each problem? Very many thanks in advance! Aaron Fude |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
protect / unprotect VBA project by macro | Excel Discussion (Misc queries) | |||
protect/unprotect a VBA Project | Excel Programming | |||
protect/unprotect a VBA Project | Excel Programming | |||
Using Send Keys to unprotect and protect VB project | Excel Programming | |||
Protect\Unprotect VBA project | Excel Programming |