Sub ExportAllVBC()
Dim ExportPath As String, ExtendName As String
Dim vbc As VBComponent
ExportPath = "E:\VBACode"
For Each vbc In Application.VBE.ActiveVBProject.VBComponents
Select Case vbc.Type
Case vbext_ct_ClassModule, vbext_ct_Document '组件属性为类模块、EXCEL对象
ExtendName = ".Cls" '设置导出文件的扩展名
Case vbext_ct_MSForm '组件属性为窗体
ExtendName = ".frm"
Case vbext_ct_StdModule '组件属性为模块时
ExtendName = ".Bas"
End Select
If ExtendName <> "" Then
vbc.Export ExportPath & "\" & vbc.name & ExtendName
End If
Next
End Sub