How can I pick out files using todays date?
I have files that have dates and times in a folder, 08-25-2010-123803654.xml, 08-25-2010-123804441.xml, 08-24-2010-123851240.xml, etc.
I want to pull out just todays entrys and when i put in my code it gives me an error.
My code is:
SourceFolder = "C:\TEST(DateTime.Now.tostring('MM-dd-yyyy-*')"
Im not sure what Im doing wrong here.
Thanks
MY Code: Module Module1
Private Property fs As Object
Private Property BaseName As Object
Private Property FullTargetPath As Object
Sub Main()
Dim xlApp, xlWkb, SourceFolder, TargetFolder, file
xlApp = CreateObject("excel.application")
fs = CreateObject("Scripting.FileSystemObject")
Const xlNormal = 1
SourceFolder = "C:\TEST\" & DateTime.Now.ToString("MM-dd-yyyy") & "*"
TargetFolder = "C:\TEST\Excel"
'Hide Excel
xlApp.Visible = False
'Process each file in SourceFolder
For Each file In fs.GetFolder(SourceFolder).files
'Open file in SourceFolder
xlWkb = xlApp.Workbooks.Open(file)
'Get Filename
BaseName = fs.getbasename(file)
'Concatenate full path. Extension will be automatically added by Excel
FullTargetPath = TargetFolder & "\" & BaseName
'Save as XLS file into TargetFolder
xlWkb.SaveAs(FullTargetPath, xlNormal)
'Close the file after its done
xlWkb.close()
Next
xlWkb = Nothing
xlApp = Nothing
fs = Nothing
MsgBox("Finished. Bout time!")
End Sub
End Module