This error
only happens when the VBProject
is locked for viewing
and I understand that Password Protection
of any kind is like Door Locks
, it is designed to Keep Honest People Out
!

This error only happens when a call is is made to the following function which references the VBIDE Library:
Function chgWsCodeName(strName, cName, Optional WB As Workbook)
Dim ws As Worksheet
Dim VBProj As VBIDE.vbProject
Dim vbComps As VBIDE.VBComponents
Dim vbComp As VBIDE.VBComponent
Dim vbProps As VBIDE.Properties
Dim CodeNameProp As VBIDE.Property
If WB Is Nothing Then Set WB = ThisWorkbook
Set ws = Worksheets(strName)
Set VBProj = WB.vbProject
Set vbComps = VBProj.VBComponents
Set vbComp = vbComps(ws.CodeName)
Set vbProps = vbComp.Properties
Set CodeNameProp = vbProps("_Codename")
CodeNameProp.Value = cName
End Function
I'm not sure why the Function
above causes the Error
only when the Project is Locked for viewing
and I have been unable to find an answer to that question! I believe I have all the necessary references selected in Tools/References
.

VBProject Properties Window
and VBProject.Protection
is only restored when the Workbook is Saved, Closed, and Reopened. Is there a method change VBProject.Protection = vbext_pp_none
back to VBProject.Protection = vbext_pp_Locked
thereby restoring VBProject.Protection
without closing and reopening the workbook? I have seen countless threads
on different Forums
stating it was impossible to access VBProject Properties
programmatically through VB
or VBA
yet as one may see from the Link to Unlock VBProject
above, the Impossible
is Possible
!
Can someone Please help me with this?
Thanks in advance for your assistance!