Exporting MS Access Forms and Class / Modules Recursively to text files?

后端 未结 6 1227
时光取名叫无心
时光取名叫无心 2020-12-01 05:57

I found some code on an ancient message board that nicely exports all of the VBA code from classes, modules and forms (see below):

Option Explicit
Option Com         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-01 06:31

    IDK why no one has suggested this before, but here is a small piece of code I use for this. Pretty simple and straightforward

    Public Sub VBAExportModule()
        On Error GoTo Errg
        Dim rs As DAO.Recordset
        Set rs = CurrentDb.OpenRecordset("SELECT MSysObjects.Name FROM MSysObjects WHERE Type=-32761", dbOpenDynaset, dbSeeChanges)
    
        Do Until rs.EOF
            Application.SaveAsText acModule, rs("Name"), "C:\" & rs("Name") & ".txt"
            rs.MoveNext
        Loop
    
    Cleanup:
        If Not rs Is Nothing Then rs.Close
        Set rs = Nothing
        Exit Sub
    Errg:
        GoTo Cleanup
    End Sub
    

提交回复
热议问题