Hello,
I am working on an Excel VBA Application that imports A CSV file every 2 minutes. Right before it imports the program clears sheet1 and then imports the Data. The CSV file is updated every 2 minutes as well. The file name changes daily, so here is my problem I want to be able to import automatically every day every two minutes. I have everything working except the automatic import with the auto name finding. The part of the program that I am stuck on is listed below. The way I need it to work is to import the "Availabili ty" this has pulled in all the information from the file Path.
Any help you can give me would be appreciated
Thanks
Dwight
I am working on an Excel VBA Application that imports A CSV file every 2 minutes. Right before it imports the program clears sheet1 and then imports the Data. The CSV file is updated every 2 minutes as well. The file name changes daily, so here is my problem I want to be able to import automatically every day every two minutes. I have everything working except the automatic import with the auto name finding. The part of the program that I am stuck on is listed below. The way I need it to work is to import the "Availabili ty" this has pulled in all the information from the file Path.
Any help you can give me would be appreciated
Thanks
Dwight
Code:
Dim myDir As String, fn As String, a(), n As Long, Availability As String
Dim myDate As Date, temp As Date
Private Sub Import()
myDir = "Q:\Manufacturing\Equipment\DispatchLogs\logs\7-DES\"
fn = Dir(myDir & "\*.csv")
Do While fn <> ""
temp = CreateObject("Scripting.FileSystemObject").Getfile(myDir & "\" & fn).DateLastModified
If myDate = 0 Then
myDate = temp: Availability = myDir & "\" & fn
Else
If myDate < temp Then myDate = temp: Availability = myDir & "\" & fn
End If
fn = Dir
Loop
If Len(Availability) Then
If vbYes = MsgBox("Opening Availability File Name : " & Availability & vbLf & _
"Last modified on : " & myDate, vbYesNo) Then
End If
End Sub
Comment