Requires a reference to the MS VBA extensibility, and acts on the
activeworkbook, but that is easy enough to change:
Sub RemoveAllVBACode()
Dim myVBA As VBIDE.VBComponent
For Each myVBA In ActiveWorkbook.VBProject.VBComponents
If myVBA.Type = vbext_ct_Document Then
With myVBA.CodeModule
.DeleteLines 1, .CountOfLines
End With
Else
ActiveWorkbook.VBProject.VBComponents.Remove myVBA
End If
Next myVBA
End Sub
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.