View Single Post
Newbie Member
20Jul2012,14:43  
tyme's Avatar
Dear all,

I manage to create the script to copy the files but i got error: Object required:" at the highlighted line, char 6. Does anyone know what is wrong with my script?

Code:
 
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
Dim objFSO
Dim strSortDate
Dim strSortDate2
Dim fso
Dim file
Dim year
DIm month
strSortDate = DatePart("yyyy",Date)
strSortDate2 = DatePart("m",Date)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fso = CreateObject("Scripting.FileSystemObject")
strSortDate = DatePart("yyyy",Date)
year = Right(strSortDate,2)
strSortDate2 = DatePart("m",Date)
 
If objFSO.FolderExists("\\servername\samplefile\" & year & "0" & strSortDate2 & "01") Then
MsgBox("Hello!")
objFSO.copyfile file.path,\\servername\prod\ & strSortDate & "" & strSortDate2 & "01\" & file.name
Else
If objFSO.FolderExists("\\servername\samplefile\" & year & "0" & strSortDate2 & "02") Then
MsgBox("gotcha!") 
objFSO.copyfile file.path, \\servername\prod\ & strSortDate & "" & strSortDate2 & "02\" & file.name
Else 
If objFSO.FolderExists("\\servername\samplefile\ & year & "0" & strSortDate2 & "03") Then
objFSO.copyfile file.path,\\servername\prod\& strSortDate & "" & strSortDate2 & "03\" & file.name

End if
set objFSO = nothing 
set fSO = nothing 
End if

Last edited by shabbir; 20Jul2012 at 15:14.. Reason: Code blocks