M
Michael McClellan
I am usually the following code to move files into proper directories
based on what they have been named at the scanner.
The problem is: I cannot get the if statement with the FileExists
method to recognize that there are files in that directory that
contain the text "HMB4129". Why is this?
Sub FileScanned()
'
' FileScanned Macro
' Macro recorded 6/23/2004 by Michael McClellan, Jr.
'
'
Dim DirVar1 As String
Dim DirVar2 As String
Dim DirVar3 As String
Dim DirVar4 As String
Dim CurrDir As String
Dim CurrFile As String
Dim rownum As Integer
Dim FilesFiled As Integer
Sheets("Orders").Select
FilesFiled = 0
rownum = 47
'Do
DirVar1 = Range("A" & rownum).Value 'office code
DirVar2 = Range("B" & rownum).Value 'HM PO#
DirVar3 = Range("F" & rownum).Value 'vendor code
DirVar4 = Range("L" & rownum).Value 'customer po
CurrDir = "HM" & DirVar1 & DirVar2 & " - " & DirVar3 & " - " &
DirVar4
CurrFile = "HM" & DirVar1 & DirVar2
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("C:\Ricoh Scan Files\*HMB4129.pdf") = True Then
fs.MoveFile "C:\Ricoh Scan Files\*" & CurrFile & ".pdf",
"R:\Orders\" & CurrDir & "\"
FilesFiled = FilesFiled + 1
End If
rownum = rownum + 1
'Loop Until DirVar2 = ""
MsgBox FilesFiled & " files were filed."
End Sub
based on what they have been named at the scanner.
The problem is: I cannot get the if statement with the FileExists
method to recognize that there are files in that directory that
contain the text "HMB4129". Why is this?
Sub FileScanned()
'
' FileScanned Macro
' Macro recorded 6/23/2004 by Michael McClellan, Jr.
'
'
Dim DirVar1 As String
Dim DirVar2 As String
Dim DirVar3 As String
Dim DirVar4 As String
Dim CurrDir As String
Dim CurrFile As String
Dim rownum As Integer
Dim FilesFiled As Integer
Sheets("Orders").Select
FilesFiled = 0
rownum = 47
'Do
DirVar1 = Range("A" & rownum).Value 'office code
DirVar2 = Range("B" & rownum).Value 'HM PO#
DirVar3 = Range("F" & rownum).Value 'vendor code
DirVar4 = Range("L" & rownum).Value 'customer po
CurrDir = "HM" & DirVar1 & DirVar2 & " - " & DirVar3 & " - " &
DirVar4
CurrFile = "HM" & DirVar1 & DirVar2
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("C:\Ricoh Scan Files\*HMB4129.pdf") = True Then
fs.MoveFile "C:\Ricoh Scan Files\*" & CurrFile & ".pdf",
"R:\Orders\" & CurrDir & "\"
FilesFiled = FilesFiled + 1
End If
rownum = rownum + 1
'Loop Until DirVar2 = ""
MsgBox FilesFiled & " files were filed."
End Sub