My workbook has the following open event:
Private Sub Workbook_Open()
ThisWorkbook.ChangeFileAccess xlReadOnly
End Sub
And then this button:
Sub UnlockDeveloper()
Dim pwd As String
pwd = InputBox("Enter developer password:", "Password")
If pwd = "password" Then
If ThisWorkbook.ReadOnly = True Then
ThisWorkbook.ChangeFileAccess xlReadWrite
End If
Else
MsgBox ("Incorrect password.")
End If
End Sub
This all works fine, usually, but sometimes running the UnlockDeveloper sub causes the VBAProject to appear twice in the VBA window, and I have no way of knowing which is the real file. If I make changes in the wrong one the changes are lost as soon as I close Excel.
Anyone got any ideas how to prevent this?