LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Move files from one directory to another: if they are there

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open files in the same directory houghi Excel Discussion (Misc queries) 2 May 21st 07 03:56 PM
Files in a directory? Greg B Excel Discussion (Misc queries) 5 May 11th 05 09:46 PM
Renaming all files in a directory Jan Kronsell[_3_] Excel Programming 4 February 19th 04 12:33 PM
macro to move contents of directory Harvey[_3_] Excel Programming 0 February 9th 04 07:36 PM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM


All times are GMT +1. The time now is 09:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"