Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A better VBA editor for Autocad

I'm developing some VBA macros in Autocad. The built-in editor is obsolete, but I wasn't able to find any better way to edit the .dvb files.

A .dvb file does contains many other source files packed in, and so far I think that Autocad is the only software that can unpack them...

The only way it seems to be able to do this, is to export every file from the .dvb manually; but since I have about 30 files there, it doesn't seem like this is a good way to do things.

Any ideas on how to do this better?

like image 789
Artur Iwan Avatar asked Feb 24 '23 18:02

Artur Iwan


1 Answers

You can export all your files with this code :

Public Sub Export()
    Dim vbe As vbe
    Set vbe = ThisDrawing.Application.vbe
    Dim comp As VBComponent
    Dim outDir As String
    outDir = "C:\\Temp\\VbaOutput"
    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 were exported to : " & outDir
End Sub
like image 137
Maxence Avatar answered Mar 03 '23 02:03

Maxence