Solved Application.VBE.ActiveVBProject.Protection (1 Viewer)

zelarra821

Registered User.
Local time
Today, 15:31
Joined
Jan 14, 2019
Messages
813
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:31
Joined
Oct 29, 2018
Messages
21,473
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")
 

zelarra821

Registered User.
Local time
Today, 15:31
Joined
Jan 14, 2019
Messages
813
Ok, I'll do it. Thanks. Maybe somebody answer.
 

zelarra821

Registered User.
Local time
Today, 15:31
Joined
Jan 14, 2019
Messages
813
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:31
Joined
Oct 29, 2018
Messages
21,473
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
 

Josef P.

Well-known member
Local time
Today, 15:31
Joined
Feb 2, 2023
Messages
826
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}"
 

zelarra821

Registered User.
Local time
Today, 15:31
Joined
Jan 14, 2019
Messages
813
Could you translate this?

Xi
%A%K
%s

It's for translate for my language.
 

Josef P.

Well-known member
Local time
Today, 15:31
Joined
Feb 2, 2023
Messages
826
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:

zelarra821

Registered User.
Local time
Today, 15:31
Joined
Jan 14, 2019
Messages
813
{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}"
 

Josef P.

Well-known member
Local time
Today, 15:31
Joined
Feb 2, 2023
Messages
826
Screenshot from English Access:
projectProperties.png

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

Pwd as "123"


Note: click {ALT} to see the underlined characters
 

zelarra821

Registered User.
Local time
Today, 15:31
Joined
Jan 14, 2019
Messages
813
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.
 

Josef P.

Well-known member
Local time
Today, 15:31
Joined
Feb 2, 2023
Messages
826
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}"
 

zelarra821

Registered User.
Local time
Today, 15:31
Joined
Jan 14, 2019
Messages
813
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:31
Joined
Oct 29, 2018
Messages
21,473
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

Top Bottom