PDA

View Full Version : [SOLVED] Remove module from closed workbook



jphermans
06-28-2005, 02:30 PM
is it possible to remove modules from a closed workbook ?
I've a lot of workbooks where i want to remove a module.

Jacob Hilderbrand
06-28-2005, 02:43 PM
Just must open each workbook.

You can have a macro open each workbook in a folder, delete the module, then save and close the workbook.

Are the projects in these workbooks password protected?
What is the module that you want to remove?

MOS MASTER
06-28-2005, 02:49 PM
Hi, :yes

Small sample you could use:


Sub DeleteCodeModule()
With Application
.ScreenUpdating = False
.Workbooks.Open ("C:\index.xls")
With .ActiveWorkbook
.VBProject.VBComponents.Remove .VBProject.VBComponents("Module2")
.Save
.Close
End With
.ScreenUpdating = True
End With
End Sub


In 2000 this will run without problems in version greater then 2000 you need to check "Trust access to vbproject" on the second tab of macro security settings.

Otherwise it won't allow you to perform this action to the VBE. :whistle: