VBAProject - Project Properties

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
690
Office Version
  1. 365
Platform
  1. Windows
I have protected my code with a password and locked project for viewing.
I would like to be able to unlock and lock the password and viewing with VBA code.
Is this possible and what would the code be.
I have done a lot of code writing but this one is above my pay grade....


Thank You
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
There is no official way. You can try SendKeys to operate the VBE menu and fill out the password dialog.
 
Upvote 0
I don't know how to use SendKeys.
What I'm trying to do Is in the opening code it will know it's my computer and unlock the project.
Any Suggestions?

Thanks for the reply
 
Upvote 0
This works for me:
VBA Code:
Public Sub HideProject()
    ' Hide project and set password to 'Pa$$w0rd'
    SendKeys "%{F11}"   ' open VBA-IDE
    VBA.DoEvents        ' wait a bit
    SendKeys "%xi"      ' menu navigation is language dependent
    SendKeys "+{Tab}{Right}{Tab}{Tab}" ' move to tab secure
    SendKeys " {Tab}{Tab}"             ' check hide checkbox with space
    SendKeys "Pa$$w0rd{Tab}"           ' fill password
    SendKeys "Pa$$w0rd{Enter}"
End Sub

 
Upvote 0
Public Sub HideProject()
' Hide project and set password to 'Pa$$w0rd'
SendKeys "%{F11}" ' open VBA-IDE I stepped through the code. When I got here it opened the main page
VBA.DoEvents ' wait a bit
SendKeys "%xi" 'menu navigation is language dependent. When I executed this line it changed i SendKeys "+{Tab}{Right}{Tab}{Tab}" ' move to tab secure
SendKeys "+{Tab}{Right}{Tab}{Tab}" ' move to tab secure
SendKeys " {Tab}{Tab}" ' check hide checkbox with space
SendKeys "123{Tab}" ' fill password I used 123 as the password
SendKeys "123{Enter}"
End Sub

When I ran it fast this is what I got

Public Sub HideProject()
' Hide project and set password to 'Pa$$w0rd'
iS Pa$$w0rd Pa$$w0rd
endKeys "%{F11}" ' open VBA-IDE I stepped through the code. When I got here it opened the main page
VBA.DoEvents ' wait a bit
SendKeys "%xi" ' menu navigation is language dependent
SendKeys "+{Tab}{Right}{Tab}{Tab}" ' move to tab secure
SendKeys " {Tab}{Tab}" ' check hide checkbox with space
SendKeys "123{Tab}" ' fill password
SendKeys "123{Enter}"
End Sub

I don't understand..

Thanks
 
Upvote 0
Take a look here and see if it works for you :
 
Upvote 0
Thank you for this tip

Sub HintForGoodResults( )
If yourcode Is indented Then
"it is easier to for everyone to understand" AND "others are more likely to give assistance"
Else
"errors are much harder to find" OR "others dont bother"
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,587
Messages
6,120,406
Members
448,958
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top