A
Adax
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.VBComponents.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
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.VBComponents.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