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?
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
If you don't feel like modifying your code with the above Export()
subroutine, you can export your VBA code from the .dvb
file using the VBA2VB Form Converter macro written by Leslie Lowe, or the modified version written by Augusto Gonçalves of the Autodesk Developer Network. This macro has the added bonus of being able to convert simple VBA forms to VB6 forms. You'll need to do this if you want to be able to port the project to .NET in the future, as AutoCAD is dropping VBA support. The modified version of the macro is especially nice, as it will create the .vbproj
ASCII file that you'll need to do the migration, which you'd otherwise need a copy of the old Visual Basic 6 IDE to make.
FWIW, A .dvb
file can be opened using an archive utility like 7-Zip, if you want to see what's in it -- but it appears to be compiled, and isn't helpful if you want human-readable or exportable code.
精彩评论