Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Open files in the same directory | Excel Discussion (Misc queries) | |||
Files in a directory? | Excel Discussion (Misc queries) | |||
Renaming all files in a directory | Excel Programming | |||
macro to move contents of directory | Excel Programming | |||
Check if directory empty OR no of files in directory. | Excel Programming |