hsingh1981
Programmer
Hi all i found code on this site which moves all files with a paticular extension. (faq707-4116)
However i made some very little alterations so it moves all .mdi files. But it only moves just one file to the destination folder. Not sure where i've gone wrong?
However i made some very little alterations so it moves all .mdi files. But it only moves just one file to the destination folder. Not sure where i've gone wrong?
Code:
Sub MoveFilesFolder2Folder()
Dim fso
'source folder path
sfol = "Y:\DischargeLetters"
'destination folder path
dfol = "Y:\DischargeLetters\EmailSent"
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
If Not fso.FolderExists(sfol) Then
MsgBox sfol & " is not a valid folder/path.", vbInformation, "Invalid Source"
ElseIf Not fso.FolderExists(dfol) Then
MsgBox dfol & " is not a valid folder/path.", vbInformation, "Invalid Destination"
Else
fso.MoveFile (sfol & "\*.mdi*"), dfol ' Change "\*.*" to "\*.mdi" to move mdi Files only
End If
If Err.Number = 53 Then MsgBox "File not found"
End Sub