Export MBVA into text files

I am attempting to export my MVBA projects as text files. I was able to get the .bas, .cls, and .frm files to export, but I am struggling with how to make the .frx file text, and how to export the project references. (Declaring Dim oRef as Reference throws a user-defined type not defined error) I used this article as a reference: https://communities.bentley.com/products/microstation/w/microstation__wiki/2889/2889

Full code here:

Public oComp As Object
Public index As Integer
Public filePath As String
Public fileName As String
Public fullfileName As String
Public fsoOutputFile As TextStream



Public Sub Finish()
    Dim projName As String
    Dim suffix As String
    Dim filetype As String
    Dim oRef As Reference
    
    filePath = "U:\Carl_Stanton\microstation_vbas"
    
    Set oVBE = Application.VBE
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    For Each oProject In oVBE.VBProjects
        projName = oProject.Name
        If doesFolderExist(filePath & "\" & oProject.Name) = False Then
            MkDir (filePath & "\" & projName)
        End If
       
        Call SetOutputFile(filePath & "\" & projName, projName & "_refs.txt")
        
        Set refsFile = objFSO.OpenTextFile(fullfileName, ForWriting, True)
        
        For Each oRef In oProject.References
        
                refsFile.WriteLine (oRef.FullPath)
            Next
        
        For Each oComp In oProject.VBComponents
                filetype = oComp.Type

                Select Case oComp.Type
                        Case "1"
                            suffix = ".bas"
                        Case "2"
                            suffix = ".cls"
                        Case "3"
                            suffix = ".frm"

                End Select
                Call SetOutputFile(filePath, oComp.Name & suffix)
                fileName = filePath & "\" & projName & "\" & oComp.Name & suffix
                oComp.Export (fileName)
                
            Next
            
        index = 1
    Next
    MsgBox ("extract complete")

        
End Sub

Public Sub Start()
    UserForm1.Show
End Sub

Public Function doesFolderExist(folderPath) As Boolean

doesFolderExist = Dir(folderPath, vbDirectory) <> ""

End Function

Public Sub SetOutputFile(file_path As String, file_name As String)
    fullfileName = file_path & "\" & file_name
    If objFSO.FileExists(fullfileName) Then
        'you delete if you find it'
        objFSO.DeleteFile fullfileName, True
    End If
End Sub

Parents Reply
  • I want to export to text so I can put the text files into version control

    VBA is ancient.  It isn't really suited to version control.  It's VB 5½, invented by Microsoft a long time ago. VBA was first launched with MS Excel 5.0 in 1993. That was before version control became commonplace.

    What version control will you use?  Can't it check binary files as well as text files?

    In the long term it would pay to move to another language more amenable to document management.  C# and C++ are both good languages for MicroStation CONNECT development and lend themselves to version control.

     
    Regards, Jon Summers
    LA Solutions

Children