How can I unprotect VBProject in workbook by VB Code?

Kreang

New Member
Joined
May 2, 2003
Messages
24
Hi all,
How can I code for unprotect and protect VBProject in my workbook by VB code? There is password also.

Thanks in advance,
Kreang
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Kreang -

VBA does not expose VBProject passwords in its object model. The way password *******s do it is by trial end error using something like SendKeys or various Windows APIs to send trial passwords to the appropriate dialog box.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______
 
Upvote 0
Hi,
I try as below

Set wbbproj = ThisWorkbook.VBProject
wbbproj.VBE.selectedvbcomponent.Select
Application.SendKeys "test", True
Application.SendKeys "~", True

but it can not use. (I use MS Excel2000)

Remarks : "test" is my password
I think, problem is line#2, How can I do the "VBProject Password window" show?
I think, if we can do the "VBAProject Password" window show, we can use sendkeys to enter password.

Thanks in advance,
Kreang
 
Upvote 0
This will unprotect a sheet. Replace "mypassword" with whatever your password is.
Code:
ActiveSheet.Unprotect Password:="mypassword"

This will password protect a sheet. Replace :mypassword" with whatever your password is.
Code:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="mypassword"

Is this what you were asking for ? :confused:

Cheers
clarence
 
Upvote 0
Hi Clarence,
I don't want to protect or unprotect worksheet ,I want to unprotect VBProject by VB code.

Thanks,
Kreang
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,167
Members
448,554
Latest member
Gleisner2

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