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
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