Convert DVB files to BAS

Discussion in 'AutoCAD' started by A-Design, Oct 7, 2004.

  1. A-Design

    A-Design Guest

    Hi,

    Is it possible to retrieve the basic codes off of the DVB files or is it
    possible to convert those file to BAS file ? Thanks,

    Afshin
     
    A-Design, Oct 7, 2004
    #1
  2. A-Design

    MP Guest

    from within the vbaide, you can select a module and "Export" to bas file
     
    MP, Oct 7, 2004
    #2
  3. A-Design

    MP Guest

    clarification:
    From the menu bar near top left of window
    File | Export
     
    MP, Oct 7, 2004
    #3
  4. A-Design

    Matthew Guest

    How would I go about creating an Add-in that did that Automatically?

    Thanks
    Matthew
     
    Matthew, Oct 7, 2004
    #4
  5. A-Design

    A-Design Guest

    Thanks for the responses.
     
    A-Design, Oct 7, 2004
    #5
  6. A-Design

    Jürg Menzi Guest

    Hi Matthew

    This one I've found a while ago...
    Modified version from Kevin Terry's function (posted 10/15/2002):
    Code:
    '-----------------------------------------------------------------------------
    ' Exports all modules, classes and forms from project into a subdirectory with
    ' the name of the current version of project and current date.
    ' Necessary references:
    ' - Microsoft Visual Basic for Applications Extensibility
    ' - Microsoft Scripting Runtime
    '
    Public Sub ProjectRevisionBackup()
    
    Dim vApp As VBIDE.VBE
    Dim vProj As VBProject
    Dim vComp As VBComponent
    Dim sPath As String
    Dim sProjPath As String
    Dim PrjNme As String
    Dim PrjVer As String
    Dim sFile As String
    Dim sProj As String
    Dim sCode As String
    Dim asFiles() As String
    Dim i As Integer
    Dim FilObj As FileSystemObject
    Dim DatObj As File
    
    Set vApp = Application.VBE
    Set FilObj = CreateObject("Scripting.FileSystemObject")
    PrjNme = "MyProject"        'Set to project name
    PrjVer = "1.01.03"          'Set to project version
    
    For i = 1 To vApp.VBProjects.Count
    If UCase(vApp.VBProjects(i).Name) = UCase(PrjNme) Then
    Set vProj = vApp.VBProjects.Item(i)
    sPath = vProj.BuildFileName
    sFile = FilObj.GetBaseName(sPath)
    sProj = sFile & ".dvb"
    sPath = FilObj.GetParentFolderName(sPath)
    End If
    Next i
    
    'build path for version
    sProjPath = sPath
    sPath = sPath & "\VBA-v" & PrjVer & "-" & Format(Date,"mm-dd-yyyy")
    
    'raise error for no path
    On Error Resume Next
    ChDir (sPath)
    'make directory
    If Err.Number = 76 Then MkDir (sPath)
    Err.Clear
    On Error GoTo 0
    
    'copy project file
    Set DatObj = FilObj.GetFile(sProjPath & "\" & sFile & ".dvb")
    DatObj.Copy sPath, True
    
    'export all components
    For i = 1 To vProj.VBComponents.Count
    Set vComp = vProj.VBComponents.Item(i)
    sFile = vComp.Name
    'test for type:
    Select Case vComp.Type
    Case vbext_ct_MSForm
    vComp.Export sPath & sFile & ".frm"
    Case vbext_ct_ClassModule
    vComp.Export sPath & sFile & ".cls"
    Case vbext_ct_StdModule
    vComp.Export sPath & sFile & ".bas"
    Case vbext_ct_Document
    vComp.Export sPath & sFile & ".cls"
    Case Else
    'do nothing
    End Select
    Next
    
    MsgBox "Remember to manually compress the project file.", vbOKOnly, _
    PrjNme & " " & PrjVer
    
    Set vApp = Nothing
    Set vProj = Nothing
    Set vComp = Nothing
    Set FilObj = Nothing
    Set DatObj = Nothing
    
    End Sub
    '-----------------------------------------------------------------------------
    
    Cheers
     
    Jürg Menzi, Oct 7, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.