VB工程中源代码导出工具

前端之家收集整理的这篇文章主要介绍了VB工程中源代码导出工具前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Sub exportVBSourceTool()

Dim ExportPath As String,ExtendName As String
Dim vbc As VBComponent
Dim i%

    'ExportPath = ThisWorkbook.Path
    ExportPath = "C:\export_VBASource"  'make sure the folder is exist before run

    For Each vbc In Application.VBE.ActiveVBProject.VBComponents
        'get module code line count
        i = ThisWorkbook.VBProject.VBComponents(vbc.Name).CodeModule.CountOfLines
        
        'if code count>=1,export
        'else skip
        If i >= 1 Then
            Select Case vbc.Type
            Case vbext_ct_ClassModule,vbext_ct_Document    'class module,excel object
                ExtendName = ".Cls"    'set extension name
            Case vbext_ct_MSForm    'form
                ExtendName = ".frm"
            Case vbext_ct_StdModule    'module
                ExtendName = ".Bas"
            End Select
            If ExtendName <> "" Then
                vbc.Export ExportPath & "\" & vbc.Name & ExtendName
            End If
        End If
    Next
End Sub
依赖库:Microsoft Visual Basic for Application Extensibility 5.3

猜你在找的VB相关文章