Protect VBE Project from Excel VBA macro

After several attempts, I was able to make a macro to protect itself (protect the VBA project in VBE).
This is very rarely used and may not be successful.

We wanted to have some code to let a macro running in Excel, to protect the VBA project, the idea was originally for unprotecting a VBA project (which could allow to hack that VBA Excel project), so I decided to share this, since it is very important for us VBA developers to know that there are ways to hack a VBA code after all.

Protect VBA project in Excel workbook with password
Password used in example below is "67"

application.SendKeys "%F11%TE+{TAB}{RIGHT}%v{TAB}67{TAB}67{ENTER}"


The line above sends key strokes to the open VBE, then protect the current project (1 project).
You can tell the % means ALT key, {TAB}, {ENTER} and {RIGHT} are for these keys.

I know, it is a very tricky and may not work all times, but this is a trick as I said, and it could be enhanced in future.

Let me know
desktop developing excel programming software vbaxlman