Function Dir(strFileExtension) 'As String 'Returns the complete path and file name of the first file 'in the script directory with the matching extension 'Dir("mdb") might return "C:\MYDOCU~1\TestFile.mdb" Dim fs 'As Scripting.FileSystemObject Dim strDir Dim fil 'As Scripting.Files Dim fils 'As Scripting.File Set fs = CreateObject("Scripting.FileSystemObject") Set fils = fs.GetFolder(fs.BuildPath(Wscript.ScriptFullName, "..\")).Files For each fil in fils If Lcase(Right(fil.name, Len(strFileExtension) + 1)) = "." & Lcase(strFileExtension) Then strDir = fil.Path End If Next Dir = strDir End Function