Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Unprotecting a VBA Project

I had to do some digging recently to try and find the answer to this,
and while I did find a couple good leads, the code wasn't *quite*
right. So, for the benefit of someone else trying to attempt to do
this crazy thing, I thought I'd post the code here. (Really, it's NOT
an ego thing...just trying to give back a little.)

NOTE: The constant "conPW " is the password to be used on the project.
The value is stored with the project at save/close, so locking the
doors when you leave isn't necessary.


Public Sub UnprotectVBAProject()
'This has been tested in E97 only.
On Error GoTo ErrHandler
Const conPW as String = "MyPassword"

'Open VBE
Call SendKeys("%{F11}", True)
'Open Project Explorer
Call SendKeys("%(V)P", True)
'PageUp 5 times to be sure "VBAProject" is selected
Call SendKeys("{PGUP 5}", True)
'Hit Enter to give prompt, enter PW and Enter again.
Call SendKeys("{ENTER}" & conPW & "{ENTER}", True)

ExitProcedu
Exit Sub

ErrHandler:
Select Case Err.Number
Case Else
Application.ScreenUpdating = True
MsgBox Err.Number & vbNewLine & Err.Description,
vbCritical
Resume ExitProcedure
Resume
End Select

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Unprotecting a VBA Project


"Anthony Cuttitta Jr." wrote in message
om...

I had to do some digging recently to try and find the answer to

this,
and while I did find a couple good leads, the code wasn't *quite*
right. So, for the benefit of someone else trying to attempt to do
this crazy thing, I thought I'd post the code here. (Really, it's

NOT
an ego thing...just trying to give back a little.)

NOTE: The constant "conPW " is the password to be used on the

project.
The value is stored with the project at save/close, so locking the
doors when you leave isn't necessary.


Public Sub UnprotectVBAProject()
'This has been tested in E97 only.
On Error GoTo ErrHandler
Const conPW as String = "MyPassword"

'Open VBE
Call SendKeys("%{F11}", True)
'Open Project Explorer
Call SendKeys("%(V)P", True)
'PageUp 5 times to be sure "VBAProject" is selected
Call SendKeys("{PGUP 5}", True)
'Hit Enter to give prompt, enter PW and Enter again.
Call SendKeys("{ENTER}" & conPW & "{ENTER}", True)

ExitProcedu
Exit Sub

ErrHandler:
Select Case Err.Number
Case Else
Application.ScreenUpdating = True
MsgBox Err.Number & vbNewLine & Err.Description,
vbCritical
Resume ExitProcedure
Resume
End Select

End Sub


Am I being simplistic, or does that mean that in order to break the
password on my VBA Projects, all someone has to do, is run that code
inside a loop, trying various values of conPW?

Surely it cannot be that trivial to unlock a project or am I just
being naive?

Alan.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Unprotecting a VBA Project

"Alan" wrote in message ...
"Anthony Cuttitta Jr." wrote in message
om...

I had to do some digging recently to try and find the answer to

this,
and while I did find a couple good leads, the code wasn't *quite*
right. So, for the benefit of someone else trying to attempt to do
this crazy thing, I thought I'd post the code here. (Really, it's

NOT
an ego thing...just trying to give back a little.)

NOTE: The constant "conPW " is the password to be used on the

project.
The value is stored with the project at save/close, so locking the
doors when you leave isn't necessary.

[snip]

Am I being simplistic, or does that mean that in order to break the
password on my VBA Projects, all someone has to do, is run that code
inside a loop, trying various values of conPW?

Surely it cannot be that trivial to unlock a project or am I just
being naive?

Alan.


Actually, my guess is that you're right. Good passwords are the key
(at least if your code is critical).

Nothing is hackproof.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Unprotecting a VBA Project

"Anthony Cuttitta Jr." wrote in message
om...


Am I being simplistic, or does that mean that in order to break the
password on my VBA Projects, all someone has to do, is run that
code inside a loop, trying various values of conPW?

Surely it cannot be that trivial to unlock a project or am I just
being naive?

Alan.



Actually, my guess is that you're right. Good passwords are the key
(at least if your code is critical).

Nothing is hackproof.


Agreed - but this seemed a little too simple for my liking.

I tried to code it, but it is not quite as simple as it seems (or
perhaps I am too simple...)

Alan.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Unprotecting a VBA Project

"Alan" wrote in message ...
"Anthony Cuttitta Jr." wrote in message
om...

Actually, my guess is that you're right. Good passwords are the key
(at least if your code is critical).

Nothing is hackproof.


Agreed - but this seemed a little too simple for my liking.

I tried to code it, but it is not quite as simple as it seems (or
perhaps I am too simple...)

Alan.


Has to be run from a command button on the spreadsheet. Can't run from debug.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 188
Default Unprotecting a VBA Project

"Anthony Cuttitta Jr." wrote in message
om...

Has to be run from a command button on the spreadsheet. Can't run
from debug.


I was running it as a sub from Tools - Macros - Run from a worksheet,
mainly since the first command was to open the VBE, which meant,
implicitly, I had to start from outside the VBE.

Why does it *have* to be run from a command button? Does that make a
difference?

Thanks,

Alan.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excell error "Can't find Project or Library" Project VBAProject Lost in Excel Excel Worksheet Functions 0 April 12th 07 04:42 PM
How to convert MS Project to MS Excel. I don't have MS Project. Jane Excel Discussion (Misc queries) 1 February 20th 06 10:01 PM
Unprotecting! Joseph Excel Programming 1 August 3rd 04 02:18 PM
Unprotecting! Joseph Excel Programming 1 August 2nd 04 03:13 PM
Accesing vba project from wb that has vba project password protected cassidyr1 Excel Programming 2 July 3rd 04 01:49 PM


All times are GMT +1. The time now is 08:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"