How to unprotect a VBProject in another workbook?

Vlip

New Member
Joined
Mar 10, 2002
Messages
49
This question has been asked before but the answers were not clear. I have created the following code from what I could gather from all the posts I've read but it does not work. Here is the code:
Sub UnlockProject()
Dim DProj As Object
Set DProj = ActiveWorkbook.VBProject

Application.VBE.MainWindow.Visible = True

For Each OpWin In DProj.VBE.Windows
If InStr(OpWin.Caption, "(") > 0 Then OpWin.Close
Next OpWin

Application.SendKeys "pword", True
Application.SendKeys "~", True

End Sub

The project is not unlocked and the pword is entered into the selected cell of the active workbook.

What am I missing?

Thanks,
Vlip
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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