VBA: Export all modules in project

Option Explicit

Sub ExportAllModules()

    Dim vbaProject As VBProject
    Dim vbaComponent As VBComponent
    
    Set vbaProject = Application.VBE.ActiveVBProject
    
    For Each vbaComponent In vbaProject.VBComponents
        If vbaComponent.Type = vbext_ct_StdModule Or vbaComponent.Type = vbext_ct_MSForm Or vbaComponent.Type = vbext_ct_ClassModule Or vbaComponent.Type = vbext_ct_Document Then
            vbaComponent.Export "<LOCATION TO SAVE FILES>" & vbaComponent.Name & ".vb"
        End If
    Next
        
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *