VBA源代码的代码比较

时间:2016-09-02 13:41:24

标签: vba autodesk-inventor codecompare

有没有办法将VBA源代码文件(如Autodesk Inventor中的.IVB文件)与另一个文件进行比较?

由于这种文件是预编译的,我必须从两个解决方案中导出每个模块并比较文件夹。

但我更愿意比较来源  我可以直接编码文件。

谢谢,最好的问候。

1 个答案:

答案 0 :(得分:0)

您可以使用此Sub:

,而不是一次导出一个文件
Public Sub Export()
    Dim vbe As vbe
    Set vbe = ThisDrawing.Application.vbe
    Dim comp As VBComponent
    Dim outDir As String
    outDir = "c:\\temp\\VBA"
    If Dir(outDir, vbDirectory) = "" Then
        MkDir outDir
    End If
    For Each comp In vbe.ActiveVBProject.VBComponents
        Select Case comp.Type
            Case vbext_ct_StdModule
                comp.Export outDir & "\" & comp.Name & ".bas"
            Case vbext_ct_Document, vbext_ct_ClassModule
                comp.Export outDir & "\" & comp.Name & ".cls"
            Case vbext_ct_MSForm
                comp.Export outDir & "\" & comp.Name & ".frm"
            Case Else
                comp.Export outDir & "\" & comp.Name
        End Select
    Next comp

     MsgBox "VBA files have been exported to: " & outDir
End Sub

您需要添加对 Microsoft Visual Basic for Applications Extensibility 5.3 的引用。