Accessing Remote Files Via VBA code in Access DB
-
Hello All, I wrote the code below planning to use it to pick out the newest database log file in a certian directory on a computer on our LAN.
Function NewestFile(Directory, FileSpec) ' Returns the name of the most recent file in a Directory ' That matches the FileSpec (e.g., "*.xls"). ' Returns an empty string if the directory does not exist or ' it contains no matching files Dim FileName As String Dim MostRecentFile As String Dim MostRecentDate As Date If Right(Directory, 1) <> "\" Then Directory = Directory & "\" FileName = Dir(Directory & FileSpec, 0) If FileName <> "" Then MostRecentFile = FileName MostRecentDate = FileDateTime(Directory & FileName) Do While FileName <> "" If FileDateTime(Directory & FileName) > MostRecentDate Then MostRecentFile = FileName MostRecentDate = FileDateTime(Directory & FileName) End If FileName = Dir Loop End If NewestFile = MostRecentFile End Function
However, the directory that I need to pass to this function when called is a filepath on a computer on the LAN and the directory I need to access is password protected. Can anyone help me out on how to do authentication using VBA code in an access DB. Thanks is advance. Frank