Option Compare Database Option Explicit Public Sub loadVCS(Optional ByVal SourceDirectory As String) If SourceDirectory = vbNullString Then SourceDirectory = CurrentProject.path & "\MSAccess-VCS\" End If 'check if directory exists! - SourceDirectory could be a file or not exist On Error GoTo Err_DirCheck If ((GetAttr(SourceDirectory) And vbDirectory) = vbDirectory) Then GoTo Fin_DirCheck Else 'SourceDirectory is not a directory err.Raise 60000, "loadVCS", "Source Directory specified is not a directory" End If Err_DirCheck: If err.number = 53 Then 'SourceDirectory does not exist Debug.Print err.number & " | " & "File/Directory not found" Else Debug.Print err.number & " | " & err.Description End If Exit Sub Fin_DirCheck: 'delete if modules already exist + provide warning of deletion? On Error GoTo Err_DelHandler Dim filename As String 'Use the list of files to import as the list to delete filename = dir$(SourceDirectory & "*.bas") Do Until Len(filename) = 0 'strip file type from file name filename = Left$(filename, InStrRev(filename, ".bas") - 1) DoCmd.DeleteObject acModule, filename filename = dir$() Loop GoTo Fin_DelHandler Err_DelHandler: If err.number <> 7874 Then 'is not - can't find object Debug.Print "WARNING (" & err.number & ") | " & err.Description End If Resume Next Fin_DelHandler: filename = vbNullString 'import files from specific dir? or allow user to input their own dir? On Error GoTo Err_LoadHandler filename = dir$(SourceDirectory & "*.bas") Do Until Len(filename) = 0 'strip file type from file name filename = Left$(filename, InStrRev(filename, ".bas") - 1) Application.LoadFromText acModule, filename, SourceDirectory & filename & ".bas" filename = dir$() Loop GoTo Fin_LoadHandler Err_LoadHandler: Debug.Print err.number & " | " & err.Description Resume Next Fin_LoadHandler: Debug.Print "Done" End Sub