Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This will sound like a strange question: Is there a way using VBA to set and reset the password for the VBAProject Properties? If so, what does the code look like? Thanks in advance.
-Warren R |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've heard there isn't a programmable way to reset the password.
SendKeys may work? -- Rob van Gelder - http://www.vangelder.co.nz/excel "WarrenR" wrote in message ... This will sound like a strange question: Is there a way using VBA to set and reset the password for the VBAProject Properties? If so, what does the code look like? Thanks in advance. -Warren R |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Rob/Warren
Here is a example with unreliable Sendkeys Old post from Bill Manville ------------------------ You will need to use SendKeys to unprotect the project(s) and reprotect after replacing the modules. Here's something to get you started: Sub TestProtect() Workbooks.Add.SaveAs "C:\Temp\Book1.xls" ProtectVBProject Workbooks("Book1.xls"), "Jack" Workbooks("Book1.xls").Close True End Sub Sub TestUnprotect() Workbooks.Open "C:\Temp\Book1.xls" UnprotectVBProject Workbooks("Book1.xls"), "Jack" End Sub Sub UnprotectVBProject(WB As Workbook, ByVal Password As String) Dim vbProj As Object 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 End Sub Sub ProtectVBProject(WB As Workbook, ByVal Password As String) Dim vbProj As Object Set vbProj = WB.VBProject 'can't do it if already locked! If vbProj.Protection = 1 Then Exit Sub Set Application.VBE.ActiveVBProject = vbProj ' now use lovely SendKeys to set the project password SendKeys "+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" & _ Password & "~" Application.VBE.CommandBars(1).FindControl(Id:=257 8, recursive:=True).Execute WB.Save End Sub Bill Manville MVP - Microsoft Excel, Oxford, England No email replies please - reply in newsgroup -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Rob van Gelder" wrote in message ... I've heard there isn't a programmable way to reset the password. SendKeys may work? -- Rob van Gelder - http://www.vangelder.co.nz/excel "WarrenR" wrote in message ... This will sound like a strange question: Is there a way using VBA to set and reset the password for the VBAProject Properties? If so, what does the code look like? Thanks in advance. -Warren R |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VBAProject | Excel Worksheet Functions | |||
How to get rid of a VBAProject? | Excel Programming | |||
VBAProject Protect | Excel Programming | |||
code in VBAProject will not run | Excel Programming | |||
How to Delete a VBAProject | Excel Programming |