Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default move all files in a directory into another

Friends,

I am having some trouble getting a function to move all files in one
directory to another and keep getting the "Path not found" error. Both
directories are there though and there are files in the source
directory. Here is the code:

Dim Line As String
Dim Office As String 'future use
Dim Cust As String
Dim Contact As String
Dim QuoteNum As String
Dim JobName As String
Dim PONum As String

Dim CurrDir As String


Line = ActiveCell.Offset(0, -4).Value
Office = ActiveCell.Offset(0, -3).Value
Cust = ActiveCell.Offset(0, -2).Value
Contact = ActiveCell.Offset(0, -1).Value
QuoteNum = ActiveCell.Value
JobName = ActiveCell.Offset(0, 1).Value
PONum = ActiveCell.Offset(0, 2).Value

QuoteDir = QuoteNum & " - " & Cust & " - " & Contact & " - " &
JobName
OrderDir = PONum & " - " & Cust & " - " & Contact & " - " & JobName

If PONum = "" Then
MsgBox ("Please Enter Purchase Order Number.")
Else

MkDir "X:\Orders 2004\" & Cust & "\" & OrderDir

'Move files into directory
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

fs.MoveFile "X:\Quotes 2004\" & Cust & " \ " & QuoteDir & "\" &
"*.*", "X:\Orders 2004\" & Cust & " \ " & OrderDir & "\"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default move all files in a directory into another

modify to suit

Sub movefile()
OldName = "C:\sourcefolder\yourfilename.xls"
NewName = "C:\destinationfolder\yourfilename.xls"
Name OldName As NewName
End Sub

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Friends,

I am having some trouble getting a function to move all files in one
directory to another and keep getting the "Path not found" error. Both
directories are there though and there are files in the source
directory. Here is the code:

Dim Line As String
Dim Office As String 'future use
Dim Cust As String
Dim Contact As String
Dim QuoteNum As String
Dim JobName As String
Dim PONum As String

Dim CurrDir As String


Line = ActiveCell.Offset(0, -4).Value
Office = ActiveCell.Offset(0, -3).Value
Cust = ActiveCell.Offset(0, -2).Value
Contact = ActiveCell.Offset(0, -1).Value
QuoteNum = ActiveCell.Value
JobName = ActiveCell.Offset(0, 1).Value
PONum = ActiveCell.Offset(0, 2).Value

QuoteDir = QuoteNum & " - " & Cust & " - " & Contact & " - " &
JobName
OrderDir = PONum & " - " & Cust & " - " & Contact & " - " & JobName

If PONum = "" Then
MsgBox ("Please Enter Purchase Order Number.")
Else

MkDir "X:\Orders 2004\" & Cust & "\" & OrderDir

'Move files into directory
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

fs.MoveFile "X:\Quotes 2004\" & Cust & " \ " & QuoteDir & "\" &
"*.*", "X:\Orders 2004\" & Cust & " \ " & OrderDir & "\"



Reply
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 all files in directory davethewelder Excel Discussion (Misc queries) 2 August 26th 08 02:01 PM
Files in a directory? Greg B Excel Discussion (Misc queries) 5 May 11th 05 09:46 PM
Move files from one directory to another: if they are there Michael McClellan Excel Programming 12 June 28th 04 12:42 AM
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 01:25 PM.

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

About Us

"It's about Microsoft Excel"