Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 184
Default Visual Basic Protection and Delete Modules

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Visual Basic Protection and Delete Modules

You are going to have difficutly with that one. You can not execute teh code
with the project locked and there is no truely effective way to unlock it...
check out the paragraph just above the bright red warning...

http://www.cpearson.com/excel/VBE.aspx
--
HTH...

Jim Thomlinson


"Jeremy" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Visual Basic Protection and Delete Modules

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.

"Jim Thomlinson" wrote:

You are going to have difficutly with that one. You can not execute teh code
with the project locked and there is no truely effective way to unlock it...
check out the paragraph just above the bright red warning...

http://www.cpearson.com/excel/VBE.aspx
--
HTH...

Jim Thomlinson


"Jeremy" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 184
Default Visual Basic Protection and Delete Modules

So is it possible for me to delete modules with visual being locked and how?


Thanks

"JLatham" wrote:

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.

"Jim Thomlinson" wrote:

You are going to have difficutly with that one. You can not execute teh code
with the project locked and there is no truely effective way to unlock it...
check out the paragraph just above the bright red warning...

http://www.cpearson.com/excel/VBE.aspx
--
HTH...

Jim Thomlinson


"Jeremy" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Visual Basic the same as Visual Studio 2008? Mike Stewart Excel Worksheet Functions 5 January 11th 09 04:58 PM
How to delete rows in visual basic Ruben Excel Discussion (Misc queries) 3 August 27th 08 09:43 AM
How to delete rows in visual basic Ruben Excel Discussion (Misc queries) 3 August 20th 08 03:50 PM
Delete Code Modules Programatically blatham Excel Discussion (Misc queries) 1 February 3rd 06 05:38 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM


All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"