Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT
Sub RemoveVBAFiles() Dim pVBAProject As VBProject Dim vbComp As VBComponent Dim i As Integer Dim n As Integer ' Get the VBA project ' Set pVBAProject = ThisWorkbook.VBProject Set pVBAProject = Application.Workbooks("Oz_main.xls").VBProject n = pVBAProject.VBComponents.Count For i = n To 1 Step -1 Set vbComp = pVBAProject.VBComponents.Item(i) Select Case vbComp.Type Case vbext_ct_StdModule If vbComp.Name <> "Module1" Then pVBAProject.VBComponents.Remove pVBAProject.VBComponents.Item(i) End If Case Else If vbComp.Name <> "ThisWorkbook" And vbComp.Name <> "Sheet1" Then pVBAProject.VBComponents.Remove pVBAProject.VBComponents.Item(i) End If End Select Next MsgBox "Sheet has been cleared of all modules" End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.