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

Hello! I want to remove about 30 modules in secend opened Workbook from
first opend Workbook -the instance excel.
This first workbook it is scheduler, wich generated periodically report from
model. This model contains about 30 modules, witch i have to remove before
report save.

In first workbook I running:

Dim objVbc As VBComponent
Set wb2 = workbooks (xxxxx)

For Each objVbc In Workbooks(wb2).VBProject.VBComponents
If objVbc.Type 0 And objVbc.Type < 4 Then
Workbooks(ActiveWorkbook.Name).VBProject.VBCompone nts.Remove
objVbc
Else
objVbc.CodeModule.DeleteLines StartLine:=1,
Count:=objVbc.CodeModule.CountOfLines
End If
Next objVbc

Unfortunately, this code does not work, but when I break the VBA code (after
this above code part ) all modules disappear and is OK!
Is it problem with refresh? What should I do? Help me , please! Thanx