Déverrouiller le code vba à partir de VBE
Bonjour,
J'ai cherché partout sur le forum pour déverrouiller le code VBA et je n'arrive pas !!
Mon besoin : J'ai une application qui tourne sur 100 sites avec du code VBA protégé (et j'ai le mot de passe) j'aimerai modifier le code source via une autre application. Kiki29 ma déja fourni le moyen de modifier un code source en employant du VBE. (http://www.developpez.net/forums/sho...d.php?t=391562)
Mon problème : je n'arrive pas à trouver la ou les instructions pour déverrouiller le projet vba ?
j'ai consulté le lien ci dessous
http://www.developpez.net/forums/sho...t=vbe+password
mais sans succès ! à l'execution de code de déverrouillage il me présente une boite de dialogue !
voici les routines :
------------------
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Sub TestProtect()
ProtectVBProject Workbooks("Proteger_deproteger.xls"), "motdepasse"
End Sub
Sub TestUnprotect()
UnprotectVBProject Workbooks("Proteger_deproteger.xls"), "motdepasse"
End Sub
Sub UnprotectVBProject(WB As Workbook, ByVal Password As String)
Dim vbProj As Object
Set vbProj = WB.VBProject
If vbProj.Protection <> 1 Then Exit Sub
Set Application.VBE.ActiveVBProject = vbProj
SendKeys Password & "~~"
Application.VBE.CommandBars(1).FindControl(ID:=2578, recursive:=True).Execute
End Sub
Sub ProtectVBProject(WB As Workbook, ByVal Password As String)
Dim vbProj As Object
Set vbProj = WB.VBProject
If vbProj.Protection = 1 Then Exit Sub
Set Application.VBE.ActiveVBProject = vbProj
SendKeys "+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" & _
Password & "~"
Application.VBE.CommandBars(1).FindControl(ID:=2578, recursive:=True).Execute
End Sub |
qui a ressu a déverrouiller le code sans avoir de boite de dialogue avec un code vba qui fonctionne sur sur Excel vba 97 a 2003 ?
Merci de votre contribution