View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Adax Adax is offline
external usenet poster
 
Posts: 12
Default modules removing problem

Uzytkownik "Chip Pearson" napisal w wiadomosci
...
The first flag I see raised is
Workbooks(ActiveWorkbook.Name).
Are you really sure you want to remove modules from the
ActiveWorkbook? A better solution is to set a reference to the
workbook whose modules you want to remove and always use that
reference. E.g.,
Dim DeleteFromWB As Workbook
Dim VBComp As VBIDE.VBComponent
Set DeleteFromWB = Workbooks("Book3.xls")
For Each VBComp In DeleteFromWB.VBProject.VBComponents
Select Case VBComp.Type
Case vbext_ct_ActiveXDesigner, vbext_ct_ClassModule, _
vbext_ct_MSForm, vbext_ct_StdModule
DeleteFromWB.VBProject.VBComponents.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp


Thank You very much! but unfortunatelyit dosn't work tooo! :) This problem
I try solve since several months and without result.
Your and my code works when I start this code from empty workbook.
When I add it to my scheduler with many modules I noticed importand
observation: when I breake code after this removing code, immediately all
modules disappears.... Problem with collection refresh? I see, missing
collection refresh...