Export VBA Excel

You can export the VBA in Excel, Word, etc. by adding a reference to the

"Microsoft Visual Basic for Applications Extensibility 5.3" and using the

following code...

(How to add a reference )

Sub Export_VBA_Excel()
    Dim Mod_UsrFrm As VBIDE.VBComponent
    Dim strExt As String
    For Each Mod_UsrFrm In ActiveWorkbook.VBProject.VBComponents
        If Mod_UsrFrm.Type = vbext_ct_StdModule Then
           strExt = ".bas"
        ElseIf Mod_UsrFrm.Type = vbext_ct_ClassModule Then
           strExt = ".cls"
        ElseIf Mod_UsrFrm.Type = vbext_ct_Document Then
           strExt = ".cls"
        ElseIf Mod_UsrFrm.Type = vbext_ct_MSForm Then
           strExt = ".frm"
        Else
           strExt = ""
        End If
        If strExt <> "" Then
           Mod_UsrFrm.Export ActiveWorkbook.Path & "\" & Mod_UsrFrm.Name & strExt
        End If
    Next
End Sub


This site is powered by Site Build It!. If you enjoy it, please check out the
Site Build It homepage
 to learn more and on how to build a success-guaranteed site with no technical skills.

Custom Search






Return from Export VBA Excel to VBA Code Samples

Return to our Homepage