strNextFile = Dir$(strSchedulesStaffFolder & "*.pdf")
While strNextFile <> ""
strTempFile = strNextFile
'Create a temp variable to do calculations to determine folder to archive
x = InStr(strTempFile, " - ")
'Get the date on the document
y = Len(strTempFile)
strTempFile = Right(strTempFile, y - x - 2)
x = InStr(strTempFile, ".pdf")
strTempFile = Left(strTempFile, x - 1)
strSchedulesStaffFolderArchive = strSchedulesStaffFolderArchive & "\" & strTempFile & "\" 'Change the archive according to date
If Dir(strSchedulesStaffFolderArchive, vbDirectory) > vbNullString Then
'Don't create anything
Else
MkDir strSchedulesStaffFolderArchive
End If
FileCopy strSchedulesStaffFolder & strNextFile, strSchedulesStaffFolderArchive & strNextFile
Kill strSchedulesStaffFolder & strNextFile
strTempFile = vbNullString
x = 0
y = 0
strNextFile = Dir$
Wend
|