E
ExcelMonkey
I am trying to use the following code (taken from a previous response to a
post by Bob Phillips) in a macro in my personal folder. It is attempting to
delete all the VBA modules in a target. I have tried to amend to only delete
modules unless its named "Print Routine". It is failing on the firsst line
of the For Next loop with Run Time Error 1004. I note that I am not sure
what role the variable VBComp is playing in the routine.
Dim VBComp As Object
Dim vbMod As Object
Dim RetainedModule As String
RetainedModule = "PrintRoutine"
For Each vbMod In ActiveWorkbook.VBProject.vbcomponents
If vbMod.Type = 1 And vbMod.Name = RetainedModule Then 'a module
with specific name
ActiveWorkbook.VBProject.vbcomponents.Remove vbMod
End If
Next vbMod
EM
post by Bob Phillips) in a macro in my personal folder. It is attempting to
delete all the VBA modules in a target. I have tried to amend to only delete
modules unless its named "Print Routine". It is failing on the firsst line
of the For Next loop with Run Time Error 1004. I note that I am not sure
what role the variable VBComp is playing in the routine.
Dim VBComp As Object
Dim vbMod As Object
Dim RetainedModule As String
RetainedModule = "PrintRoutine"
For Each vbMod In ActiveWorkbook.VBProject.vbcomponents
If vbMod.Type = 1 And vbMod.Name = RetainedModule Then 'a module
with specific name
ActiveWorkbook.VBProject.vbcomponents.Remove vbMod
End If
Next vbMod
EM