I suppose you could add code to module 1 to unprotect the project it's in, then reprotect itself once you've removed module 2. Would this be suitable for your needs?
On Jun 4, 8:08 pm, mikeallen7 <mikealle...@gmail.com> wrote: > I have 2 vba modules that are both within a protected project. I wish > to remove one module via code from the other module. I have this in > "module1": > > ThisWorkbook.VBProject.vbcomponents.Remove > ThisWorkbook.VBProject.vbcomponents("module2") > > It works fine IF I have the project unprotected, but the problem > arises when the project is protected. I get: > > Run-time error '50289': Can't perform operation since the project is > protected. > > Someone suggested once to go to Tools--Macros--Security--Trusted > Publishers--Trust access to Visual Basic project (click box). I have > this done, but still does not work when protected. I must have > project protected because others will be using this file and I do not > want them to have access to the sensitive code in 'module2'. The > users will need 'module2' initially to run program, then they will be > converting the program into an output-only file w/ no 'module2'. > > Thanks --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---