1

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

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

但如果可以的话,我更愿意直接比较源代码文件。

谢谢,最好的问候。

4

1 回答 1

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的引用。

于 2016-09-05T07:27:14.623 回答