Thread: Delete VB issue
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
LiAD LiAD is offline
external usenet poster
 
Posts: 386
Default Delete VB issue

Hi,

I have this code to try to delete whatever code is inside a file but it
doesn't seem to work. Would some-one be able to tell me why please or what
code I should use to delete whatever VB is in a file?

Thanks
LiAD


Sub DeleteAllVBA()

Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ActiveWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
..DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp
End Sub