Project is protected--Can't perform operation...??? (1 Viewer)

jdraw

Super Moderator
Staff member
Local time
Today, 07:37
Joined
Jan 23, 2006
Messages
15,379
50289 --Can't perform operation because the project is protected.

My routine calls code that uses the VBIDE to list the procedures in the user database.
I am receiving the above error and can not determine why it is protected. I created the routine
and did not do anything intentional (AFAIK) to protect it.
This is an initial attempt to use VBIDE programming so I may have missed something obvious.

Does anyone have an explanation or suggestion to resolve this?
Thanks in advance.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:37
Joined
Sep 21, 2011
Messages
14,311
So is it locked in the project properties Jack?
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:37
Joined
Jan 23, 2006
Messages
15,379
Paul,
Nothing here. Is there somewhere else I should be checking?
To clarify, I'm not trying to protect anything. I just want to use a routine that uses
VBE and components to identify and store procedure names for some subsequent processing.
1678725257262.png

1678725257262.png
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 12:37
Joined
Sep 21, 2011
Messages
14,311
Yes, I understand that, just thought it was worth checking? :(

EDit, see if this works for you at least?


Specifically I stumbled onto the fact if I put a break at the beginning of my VBIDE code I don’t get the error
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:37
Joined
Jan 23, 2006
Messages
15,379
Paul,
Thanks for the link and response. I tried putting a break at start of VBIDE code but still get the error.
Do you do much programming of the VBE/VBIDE? I don't. I just want a list of all procs in the user database, to see which are not being used.
I'm not trying to protect anything.
 

Josef P.

Well-known member
Local time
Today, 13:37
Joined
Feb 2, 2023
Messages
827
Are you using the right VBProject reference?
VBE.ActiveVBProject does not necessarily have to be that of CurrentDb-File.
Check: YourVbProjectReference.FileName = UncPath(CurrentDb.Name)

Do you start the code via an add-in or from outside?
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 12:37
Joined
Sep 21, 2011
Messages
14,311
Paul,
Thanks for the link and response. I tried putting a break at start of VBIDE code but still get the error.
Do you do much programming of the VBE/VBIDE? I don't. I just want a list of all procs in the user database, to see which are not being used.
I'm not trying to protect anything.
Nope, never used it.
I was only ever a dabbler with Access. :)
 

moke123

AWF VIP
Local time
Today, 07:37
Joined
Jan 11, 2013
Messages
3,920
I've done quite a bit of poking around with vbe/vbide a while back and I recall getting a similiar error, but for the life of me can't remember how I got around it.

Perhaps post your code and it may stand out to someone.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:37
Joined
Sep 21, 2011
Messages
14,311
I can try it out in my test db?
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:37
Joined
Jan 23, 2006
Messages
15,379
Well for reference, I am a dabbler in VBIDE. I have been trying to build an Add-In. I provided my version 1 and 2 to a couple of people to try and provide feedback. They are busy with other projects and have not reviewed it. I did get some feedback on version 1 -- "it was helpful, and I found a few things that aren't accounted for." I modified thosein version1 and they worked

So, in the meantime, I found some vbe/VBIDE info.
I found a routine to identify procedures in the VBE Active project. I adjusted that to give the info for all vbprojects in the application, and that worked well in stand alone. That is, I took a sample database and the added my vbe code to that database. I got info for procs in all forms and all modules. I then adjusted the code to ignore/bypass specific items. And that worked standalone.
Code:
If Not (vbcomp.Name Like "DF_*" Or _
                              vbcomp.Name Like "*trackProc*") Then   'bypass tpu routine itself

It's when I made an add-in of my code, and then using a sample database and referencing the addin, the 50289 protection error occurs. I want to note that this was my first attempt with an add-in and now first with VBIDE.

Specific to Josef:
I am trying to look at all vbprojs in the application (at least that's what I think I'm doing).
Code:
        Dim vbp As VBProject
          Dim vbcomp As VBComponent
10        For Each vbp In VBE.VBProjects           'iterate over all vbProjs

             Debug.Print "ProjFile: " & vbp.FileName, "ProjName: " & vbp.Name
20            For Each vbcomp In vbp.VBComponents
     
30                With vbcomp.CodeModule                    'module or form code

Specific to moke123:

It is pretty rough at the moment. Lot's of debugging info to ensure I'm getting to specific points in the code.
Prefer not to post, but will post pieces if relevant.

Thanks for looking.
 
Last edited:

Josef P.

Well-known member
Local time
Today, 13:37
Joined
Feb 2, 2023
Messages
827
I am trying to look at all vbprojs in the application
Maybe there is a VBProject that is locked.

If you only want to have the VBProject from CurrentDb:
https://github.com/AccessCodeLib/AccessCodeLib/blob/master/_codelib/addins/shared/VbeTools.cls ... Property: CurrentVbProject

/edit:
Tested with a loaded compiled add-in (accde):
Code:
Dim vbp As Object
Dim vbc As Object 'VBComponent

For Each vbp In VBE.VBProjects
   Debug.Print "ProjFile: " & vbp.FileName, "ProjName: " & vbp.Name
   For Each vbc In vbp.VBComponents  '<-- Err 50289 raised at the compiled add-in
      Debug.Print vbc.Name
   Next
Next
 
Last edited:

sonic8

AWF VIP
Local time
Today, 13:37
Joined
Oct 27, 2015
Messages
998
I am trying to look at all vbprojs in the application (at least that's what I think I'm doing).
Code:
Code:
        Dim vbp As VBProject
          Dim vbcomp As VBComponent
10        For Each vbp In VBE.VBProjects           'iterate over all vbProjs
Check for
Code:
If vbp.Protection = vbext_pp_none  Then
otherwise you will include VB projects from libraries and add-ins, which might be protected and will raise the error you were seeing.
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:37
Joined
Jan 23, 2006
Messages
15,379
Thank you Josef. I'll give it a try.
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:37
Joined
Jan 23, 2006
Messages
15,379
Thanks sonic8/Phil
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:37
Joined
Jan 23, 2006
Messages
15,379
... Then why go through all the VBProjects?
In my process I am getting a list of procs( subs and functions )as they are executed (ActionedProcs) in user code.
The vbprocs is a list of all procs. My intent (next version) is to get the difference between
AllProcs and Actioned Procs to see what is not being used in this particular session.

I just need AllProcs from the user database (currentdb). The code I found was for ActiveProject, but I want to run the code from the Add-in. And by doing so, I got the procs within the addin. Your code gets me the procs from user database. Thank you.
Now it's back to some logic issues.

1678742783481.png
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:37
Joined
Jan 23, 2006
Messages
15,379
For anyone following this, the error "50289 --Can't perform operation because the project is protected."
can be attributed to my trying to process a builtin module that was marked protected.
When I added the condition mentioned by sonic8 in post 12, the issue was resolved.
 

Users who are viewing this thread

Top Bottom