我正在 Autocad 中开发一些 VBA 宏。内置编辑器已过时,但我找不到更好的方法来编辑.dvb
文件。
一个.dvb
文件确实包含许多其他打包的源文件,到目前为止,我认为 Autocad 是唯一可以解压缩它们的软件......
似乎能够做到这一点的唯一方法是.dvb
手动导出每个文件;但由于我在那里有大约 30 个文件,所以这似乎不是一个好方法。
关于如何更好地做到这一点的任何想法?
您可以使用以下代码导出所有文件:
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.