3 replies
Sub RemoveModules()
?**********
?Program to Remove Code & Modules Without Saving
?Charles Byrne 10/11/2000
?Office Version Compat:
?Office 97 - Tested and Works, Office 2000 - Not Tested
?Add Reference to File that contains code:
?
?In Office 97
?Microsoft Visual Basic for Applications Extensibility
?C:\Program Files\Common Files\Microsoft Shared\VBA\Vbeext1.olb
?
?In Office 2000
?Microsoft Visual Basic for Applications Extensibility 5.3
?C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\Vbe6ext.olb
?**********
Dim x As Integer, intVBProjCnt As Integer, intAns As Integer
Dim lngLineCnt As Long
Dim strProj As String, strWkbk As String
Dim vbProj As VBProject
Dim vbc As VBComponent
Dim Wkbk As Workbook
?Set Object Variables
Set Wkbk = ActiveWorkbook
Set vbProj = Wkbk.VBProject
strWkbk = Wkbk.Name
strProj = Wkbk.VBProject.Name
intAns = MsgBox("Remove Modules and Forms from " & _
strWkbk & "'s project (" & strProj & ")?", _ vbYesNo + vbQuestion, "Remove Without Saving")
If intAns = vbYes Then
?Remove Modules, Class Modules, Forms
For Each vbc In vbProj.VBComponents
If vbc.Type = vbext_ct_StdModule Then
vbProj.VBComponents.Remove vbc
ElseIf vbc.Type = vbext_ct_ClassModule Then
vbProj.VBComponents.Remove vbc
ElseIf vbc.Type = vbext_ct_MSForm Then
vbProj.VBComponents.Remove vbc
Else ?remove code lines from other objects with code
lngLineCnt = vbc.CodeModule.CountOfLines
If lngLineCnt > 0 Then
vbc.CodeModule.DeleteLines 1, lngLineCnt
End If
End If
Next vbc
End If
Set Wkbk = Nothing
Set vbProj = Nothing
End Sub
by thelanlady
by thelanlady
This discussion is closed to new replies.
Trending Desktop posts
Sort by Trending