CylonLove4Life
Technical User
Is there any way I can dump all of the VB source code - for all the forms and modules - into a text file?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function DocumentModule(RootDirectory As String, ExportBas As Boolean, ExportText As Boolean)
'Make sure a root directory was specified
If Len(RootDirectory) = 0 Then
Exit Function
End If
Dim objProj As VBProject
Dim objComponent As VBComponent
Dim intFile As Integer
Dim strModule As String
Set objProj = Application.VBE.ActiveVBProject
For Each objComponent In objProj.VBComponents
'Export the files as *.bas files
If ExportBas Then
objComponent.Export RootDirectory & "\" & objComponent.Name & ".bas"
End If
'Export the modules as *.txt files
If ExportText Then
intFile = FreeFile
Open RootDirectory & "\" & objComponent.Name & ".txt" For Output As #intFile
strModule = objComponent.CodeModule.Lines(1, objComponent.CodeModule.CountOfLines)
Print #intFile, strModule
Close #intFile
End If
Next objComponent
'Clean up
Set objComponent = Nothing
Set objProj = Nothing
End Function