RE: identifying, copying, and renaming the newest CSV file for imp
- From: "Bill R via AccessMonster.com" <u9289@uwe>
- Date: Tue, 29 Nov 2005 21:04:22 GMT
Works like a charm! Thanks a million. Western civilization is saved!
Klatuu wrote:
>I think your idea of looking for the most recent is good provided you are
>confident you will alway get the correct file. So, here is how to use the
>FileSearh object to do what you want:
>
>Sub GetLatestFile
>Dim fs as Object
>Dim lngFileCount as Long
>Dim dtmHighTime As Date
>Dim strHighName As Sting
>Dim strCurrFile As String
>Dim strPath as String
>Dim strOldFile as String
>
>'Set up the search
> set fs = application.FileSearch
> With fs
> .newsearch
> .lookin = "C:\PathToFilesYouWant"
> .filename = "*.csv"
> .searchsubfolders = false
> .execute
>'Look for the Newest file
> For lngFileCount = 1 to .foundfiles.count
> strCurrFile = .foundfiles(lngFileCount)
> If Instr(strCurrFile, "Meth_Full" = 0) Then ' We Dont Want this
>one
> If FileDateTime(strCurrFile) > dtmHighTime Then ' It is Newer
> dtmHighTime = FileDateTime(strCurrFile)
> strHighName = strCurrFile 'Keep track of the most
>recent file
> End If
> End If
> End With
>
> strPath = left(strHighName,instrrev(strHighName,"\")) 'Get the path
> strOldFile = strPath & "DMS_Report.CSV" 'Add the file name
> Kill strOldFile 'Delete the old file
> FileCopy strHighName, strOldFile Copy the new file
>
>End Sub
>
>> The file I want is:
>>
>[quoted text clipped - 28 lines]
>> >>
>> >> Bill
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-externaldata/200511/1
.
- Follow-Ups:
- References:
- identifying, copying, and renaming the newest CSV file for import
- From: Bill R via AccessMonster.com
- RE: identifying, copying, and renaming the newest CSV file for import
- From: Bill R via AccessMonster.com
- RE: identifying, copying, and renaming the newest CSV file for imp
- From: Klatuu
- identifying, copying, and renaming the newest CSV file for import
- Prev by Date: Re: Access import off Fox Pro Tables
- Next by Date: Re: Access import off Fox Pro Tables
- Previous by thread: RE: identifying, copying, and renaming the newest CSV file for imp
- Next by thread: RE: identifying, copying, and renaming the newest CSV file for imp
- Index(es):
Relevant Pages
|