I've modified the code for UN-protecting Excel VBA Project to work with Microsoft Project from the link below.
Unprotect VBProject from VB code
But in MS Project there is always a Global.mpt(my code runs from here) and when the below line executes
projAp.VBE.CommandBars(1).FindControl(ID:=2578, recursive:=True).Execute
it always opens the VBA Project Properties of the Global.mpt file.
How do I select my Project Plan's VBA Project Properties? Is there a Windows API function that would let me choose the second VBA Project Shown in the screen host. Launching the FindControl command after selecting the proejct should launch it corresponding VBA Project Properties(Manually tried this).
projAp
as VBIDE.Project possibly – user2140173debug.Print projAp.ActiveProject.VBProject.VBE.VBProjects.Item(1).FileName
C:\Users\IBM_ADMIN\AppData\Roaming\Microsoft\MS Project\14\1033\Global.mptdebug.Print projAp.ActiveProject.VBProject.VBE.VBProjects.Item(2).FileName
C:\Users\IBM_ADMIN\Desktop\Project Plan v2.46.mptprojAp.VBE.VBProjects.Item(2).VBE.CommandBars(1).FindControl(ID:=2578, recursive:=True).Execute
Even if I explicitly select the second VBAProject as in code snippet above the first VBA Project Properties only opens again. – RamY