+ Reply to Thread
Results 1 to 2 of 2

move all files in a directory into another

Hybrid View

  1. #1
    michael_mcclellan@hotmail.com
    Guest

    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. #2
    Don Guillett
    Guest

    Re: 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
    donaldb@281.com
    <michael_mcclellan@hotmail.com> wrote in message
    news:1106575184.064742.134550@z14g2000cwz.googlegroups.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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1