C
Conan Kelly
Hello all,
I found this code in a previous post to move files with code:
Sub test()
MoveAllFiles "P:\new-journals", "P:\processed-journals"
End Sub
Sub MoveAllFiles(Source As String, Dest As String)
Dim objFS As New FileSystemObject
Dim objSource As Folder
Dim objDest As Folder
Dim objFile As File
On Error GoTo MoveAllFiles_Err:
If objFS.FolderExists(Source) Then
If objFS.FolderExists(Dest) Then
Set objSource = objFS.GetFolder(Source)
Set objDest = objFS.GetFolder(Dest)
For Each objFile In objSource.Files
objFile.Move (objDest.Path & _
Application.PathSeparator & objFile.Name)
Next
Else
Err.Raise vbObjectError + 1001, "", _
"Folder " & Source & " not found."
End If
Else
Err.Raise vbObjectError + 1001, "", _
"Folder " & Source & " not found."
End If
Exit Sub
MoveAllFiles_Err:
With Err
.Raise .Number, "[MoveAllFiles]" & .Source, _
.Description, .HelpFile, .HelpContext
End With
End Sub
With this example, I can modify this code to get it to do what I want.
The problem that I'm having is that in the line of code:
Dim objFS As New FileSystemObject
it appears that my system doesn't recognize "FileSystemObject" as a
valid data type.
Do I need to reference another library for this to work?
Any help anyone can provide will be greatly appreciated,
Conan Kelly
I found this code in a previous post to move files with code:
Sub test()
MoveAllFiles "P:\new-journals", "P:\processed-journals"
End Sub
Sub MoveAllFiles(Source As String, Dest As String)
Dim objFS As New FileSystemObject
Dim objSource As Folder
Dim objDest As Folder
Dim objFile As File
On Error GoTo MoveAllFiles_Err:
If objFS.FolderExists(Source) Then
If objFS.FolderExists(Dest) Then
Set objSource = objFS.GetFolder(Source)
Set objDest = objFS.GetFolder(Dest)
For Each objFile In objSource.Files
objFile.Move (objDest.Path & _
Application.PathSeparator & objFile.Name)
Next
Else
Err.Raise vbObjectError + 1001, "", _
"Folder " & Source & " not found."
End If
Else
Err.Raise vbObjectError + 1001, "", _
"Folder " & Source & " not found."
End If
Exit Sub
MoveAllFiles_Err:
With Err
.Raise .Number, "[MoveAllFiles]" & .Source, _
.Description, .HelpFile, .HelpContext
End With
End Sub
With this example, I can modify this code to get it to do what I want.
The problem that I'm having is that in the line of code:
Dim objFS As New FileSystemObject
it appears that my system doesn't recognize "FileSystemObject" as a
valid data type.
Do I need to reference another library for this to work?
Any help anyone can provide will be greatly appreciated,
Conan Kelly