以下代码,仅供参考:
删除所有模块 Sub DeleteAllModules() Dim VBComp As Object For Each VBComp InThisWorkbook.VBProject.VBComponents If VBComp.Type = 1 Then ThisWorkbook.VBProject.VBComponents.Remove VBComp End If Next VBComp End Sub 删除所有窗体“UserForm1” Sub DeleteUserForm() Dim VBComp As Object For Each VBComp In ThisWorkbook.VBProject.VBComponents If VBComp.Type = 3 And VBComp.Name ="UserForm1" Then ThisWorkbook.VBProject.VBComponents.Remove VBComp Exit For End If Next VBComp End Sub 删除所有类模块 Sub DeleteAllClassModules() Dim VBComp As Object For Each VBComp InThisWorkbook.VBProject.VBComponents If VBComp.Type = 2 Then ThisWorkbook.VBProject.VBComponents.Remove VBComp End If Next VBComp End Sub
|