'Option Explicit Public files() Dim sAdminpad As String Sub Main 'get the folder info sAdminpad = BrowseFolder() If (FindFiles(sAdminpad & "\", "dbc", files) = True) Then count = UBound(files) For i = 0 To count dbName = "transact.IMD" Client.ImportODBCFile "`transact`", dbName, FALSE, ";DSN=Visual FoxPro Database;UID=;PWD=_IDEA922_000;SourceDB=C:\Users\dino\Desktop\BET_17\ADMBBBH1.DBC;SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;", "" Client.OpenDatabase (dbName) Next i End If client.refreshFileExplorer MsgBox "All DBC files imported" End Sub Function BrowseFolder() Dim oFolder, oFolderItem Dim oPath, oShell, strPath Dim msg As String Set oShell = CreateObject( "Shell.Application" ) Set oFolder = oShell.Namespace(17) Set oFolderItem = oFolder.Self strPath = oFolderItem.Path msg = "Please select your working directory where" msg = msg & Chr(10) & "the excel files are located:" Set oFolder = oShell.BrowseForFolder(0, msg, 1, strPath ) If oFolder Is Nothing Then BrowseFolder = "" Exit Function End If Set oFolderItem = oFolder.Self oPath = oFolderItem.Path BrowseFolder = oPath End Function Private Function FindFiles(path As String, ext As String, files()) Dim ffile As String ffile = Dir$(path & "*." & ext) If Len(ffile) = 0 Then Exit Function '-------- Dir ext = *.ext* fixing by checking length Do firstbackspace = StrReverse (ffile) firstbackspacenum = InStr(1,firstbackspace, ".") importname = Right(ffile, firstbackspacenum - 1) If Len(importname) = Len(ext) Then If Not IsNull(ffile) Then '-------- If one value found return function true and redim array If (FindFiles = False) Then ReDim files(0) FindFiles = True Else ReDim Preserve files(UBound(files) + 1) End If files(UBound(files)) = ffile Else Exit Do End If End If ffile = Dir Loop Until Len(ffile) = 0 End Function