Solved Application.VBE.ActiveVBProject.Protection

zelarra821

Registered User.
Local time
Today, 12:37
Joined
Jan 14, 2019
Messages
850
Buenas tardes.

I'm looking for a way to remove the VBA project protection (I know the password), set the project name, and then put the same password back. I have this:

Code:
    If Application.VBE.ActiveVBProject.Protection = 0 Then
        Application.VBE.VBProjects(Application.VBE.ActiveVBProject.Name).Name = DLookup("TituloAplicacion", "T00Configuracion")
    End If

I know that it has to be done using SendKeys, but I can't find the key. When I run the code and go into the project properties, the password is still there.

Can someone tell me how to do it?

Thank you.
 
I'm not sure how to remove the protection either, but this line:
Code:
Application.VBE.VBProjects(Application.VBE.ActiveVBProject.Name).Name = DLookup("TituloAplicacion", "T00Configuracion")
could probably be simplified like this, no?
Code:
Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
 
Ok, I'll do it. Thanks. Maybe somebody answer.
 
I've proved with this, but it doesn't work:

If Application.VBE.ActiveVBProject.Protection = 0 Then
SendKeys "%{F11}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{TAB}~", True
Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
End If
 
I've proved with this, but it doesn't work:

If Application.VBE.ActiveVBProject.Protection = 0 Then
SendKeys "%{F11}{*}{*}{*}{*}{*}{*}{*}{*}{*}{*}{TAB}~", True
Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
End If
Try checking for a 1 instead.
Code:
If Application.VBE.ActiveVBProject.Protection = 1 Then
 
From Colin:

Sendkeys are language dependent.

For a German Access they look like this:
Code:
SendKeys "%Xi+{TAB}{RIGHT}%A%K" & Pwd & "%s" & Pwd & "{TAB}{ENTER}"
 
Could you translate this?

Xi
%A%K
%s

It's for translate for my language.
 
Try to open the project properties from the keyboard.
Colins code is for English Access menu.

In German Access:
{Alt} + X ... Open "Extras" menu
then "i" open "Eigenschaften von ...."
{shift}+{Tab} select Tabs
{right} go to 2. tab
....

English menu:
SendKeys "%TE+{TAB}{RIGHT}%V%P" & Pwd & "%C" & Pwd & "{TAB}{ENTER}"

%T ... open "Tools" menu in VBE
"e" ... select "<your project name> Properties"
+{Tab} ... select tabs
....
 
Last edited:
{Alt} + X ... Open "Extras" menu --> In my case, Herramientas (H)
then "i" open "Eigenschaften von ...." --> In my case, Propiedades de (P)

Now, I have to know where it means:

%A%K
%s

And how I have to put the password

Pwd = "1234"
Or
Pwd = "{1}{2}{3}{4}"
 
Screenshot from English Access:
projectProperties.png

"...%V%P" & Pwd & "%C" & Pwd & "{TAB}{ENTER}"

Pwd as "123"


Note: click {ALT} to see the underlined characters
 
I almost got it. The code is this:

Code:
    If Application.VBE.ActiveVBProject.Protection = 1 Then
        MsgBox "VBA protegido"
        SendKeys "%{F11}%C" & Pwd & "{ENTER}"
        Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
        SendKeys "%HP+{TAB 9}{RIGHT}%B%C" & Pwd & "%o" & Pwd & "{TAB}{ENTER}"
    Else
        Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
        SendKeys "%HP+{TAB}{RIGHT}%B%C" & Pwd & "%o" & Pwd & "{TAB}{ENTER}"
    End If

The only thing that I want to get is locking project from viewing. I need to know what I have to put between %B%C to accept this option.
 
Which letter is underlined in this option?
In the English version it is the letter v (from viewing).
SendKeys "%TE+{TAB}{RIGHT}%V%P" & Pwd & "%C" & Pwd & "{TAB}{ENTER}"
 
B

I got it. This is the code for Spanish Access:

Code:
    If Application.VBE.ActiveVBProject.Protection = 1 Then
        SendKeys "%{F11}%C" & Pwd & "{ENTER}"
        Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
        SendKeys "%HP+{TAB}{RIGHT}%B%C" & Pwd & "%o" & Pwd & "{TAB}{ENTER}"
    Else
        Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
        SendKeys "%HP+{TAB}{RIGHT}%B%C" & Pwd & "%o" & Pwd & "{TAB}{ENTER}"
    End If
 
B

I got it. This is the code for Spanish Access:

Code:
    If Application.VBE.ActiveVBProject.Protection = 1 Then
        SendKeys "%{F11}%C" & Pwd & "{ENTER}"
        Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
        SendKeys "%HP+{TAB}{RIGHT}%B%C" & Pwd & "%o" & Pwd & "{TAB}{ENTER}"
    Else
        Application.VBE.ActiveVBProject.Name = DLookup("TituloAplicacion", "T00Configuracion")
        SendKeys "%HP+{TAB}{RIGHT}%B%C" & Pwd & "%o" & Pwd & "{TAB}{ENTER}"
    End If
Hi. Glad to hear you got it sorted out. Cheers!
 

Users who are viewing this thread

Back
Top Bottom