I know this is late, but hopefully this will help someone.
Here is some code that will get you started.
If you want to iterate through a folder, working on each MDB file (or any file for that matter), here’s some sample code using Scripting Runtime library. I’m assuming that the folder contains a mix of mdb and other files.
(make sure to set a reference to Microsoft Scripting Runtime)
Sub LoopThroughFiles()
Dim strFiletype As String
Dim strMyFilename As String
Dim fso As Scripting.FileSystemObject
Dim objFile As Object
Const strFolder As String = “C:” ‘ replace this with the path to the folder
Set fso = New Scripting.FileSystemObject
For Each objFile In fso.GetFolder(strFolder).Files
strMyFilename = objFile.Name
strFiletype = Right$(strMyFilename, 3)
If UCase$(strFiletype) = “MDB” Then
‘ your code to add a module here
End If
Next objFile
End Sub
Discuss This Question: