VB工程中源代码导出工具

来源:互联网 发布:免费工作流引擎 java 编辑:程序博客网 时间:2024/06/06 01:23

Sub exportVBSourceTool()Dim ExportPath As String, ExtendName As StringDim vbc As VBComponentDim 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    NextEnd Sub

依赖库:Microsoft Visual Basic for Application Extensibility 5.3

另,执行时可能需要设置宏安全:File -> Options -> Truest Center -> Micro Settings


0 0
原创粉丝点击