Visual Basic Protection and Delete Modules

J

Jeremy

I have in my visual basic the following code

' Deletes Modules
Set vbCom = Application.VBE.ActiveVBProject.VBComponents

vbCom.Remove VBComponent:= _
vbCom.Item("Module1")
vbCom.Remove VBComponent:= _
vbCom.Item("Module2")
vbCom.Remove VBComponent:= _
vbCom.Item("Module3")
vbCom.Remove VBComponent:= _
vbCom.Item("Module4")

This macro is held in module 8 and when the code is ran it works if visual
is unprotected but give run-time error 50289: can't perform operation since
the project is protected when the visual is protected.

How do I run this macro with visual protected?


Thank you
 
J

JLatham

The interesting thing is the hint about SendKeys. I actually tried that
approach a few weeks ago and got it to work (interesting security hole) in
Excel 2003 and even 2007 on Windows XP systems. However, there was an issue
in the way that the SendKeys were being handled in Excel 2007 on a Vista
system and I couldn't achieve the same effect (granting permission to access
the VBA Project) in that setup; the last keys needed to complete the sequence
didn't end up getting sent to the ribbon control as needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top