I am using the following code to delete code modules from my Excel 2003 workbook:
This works great unless the code is password protected, and the code modules have not been opened with the correct password. In that case, an error message is posted that the code cannot be excuted since the code modules are protected. Is there a way to delete password-protected code regardless of whether the code modules have been opened or not?
Thanks,
Paul Hudgens
Denver
Code:
Set ThisVBProject = ActiveWorkbook.VBProject.VBComponents
For Each VBCom In ThisVBProject
If LCase(VBCom.Name) = "fracfill" Then ThisVBProject.Remove ThisVBProject(VBCom.Name)
Next VBCom
For Each VBCom In ThisVBProject
If LCase(VBCom.Name) = "pd_plot" Then ThisVBProject.Remove ThisVBProject(VBCom.Name)
Next VBCom
For Each VBCom In ThisVBProject
If LCase(VBCom.Name) = "fracspacing" Then ThisVBProject.Remove ThisVBProject(VBCom.Name)
Next VBCom
This works great unless the code is password protected, and the code modules have not been opened with the correct password. In that case, an error message is posted that the code cannot be excuted since the code modules are protected. Is there a way to delete password-protected code regardless of whether the code modules have been opened or not?
Thanks,
Paul Hudgens
Denver