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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Jon Peltier

MrExcel MVP
Joined
May 14, 2003
Messages
4,962
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
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
_______
 

Kreang

New Member
Joined
May 2, 2003
Messages
24
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
 

clarence

New Member
Joined
Mar 10, 2003
Messages
26
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
 

Kreang

New Member
Joined
May 2, 2003
Messages
24
Hi Clarence,
I don't want to protect or unprotect worksheet ,I want to unprotect VBProject by VB code.

Thanks,
Kreang
 

Watch MrExcel Video

Forum statistics

Threads
1,129,471
Messages
5,636,505
Members
416,919
Latest member
twc2c

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
Top