Deleting all modules in another wb via VB

BJH1995

New Member
Joined
May 20, 2019
Messages
18
Hi All,

I currently have some code which accesses a list of workbooks, manipulates them etc.

I also want this to remove all VB modules within them to which i have the below code(snipped):

Dim Element As Object
For Each Element In wb2.VBProject.VBComponents
wb2.VBProject.VBComponents.Remove Element
Next


This doesn't seem to work as the modules it is attempting to remove are within a password protected project.I do know the password but i am unsure as to how to input this within the code if at all possible if anyone can assist.

Apologies if this makes no sense.

Thanks,
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Why not just save them as xlsx files, that will remove all the code?
 
Upvote 0
I infact did take that route which you just assisted me on with another thread! thanks again
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,673
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top