+ Reply to Thread
Results 1 to 9 of 9

copying files from one location into another.

  1. #1
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    copying files from one location into another.

    Hello again,

    Leith answered my question here, but I realized I asked the wrong question.

    http://www.excelforum.com/excel-prog...xcel-data.html

    This works, but is there a way to make it copy files from the original path to the destination rather than just relocate them?

    Thanks Again!
    Last edited by CWinkler; 04-29-2011 at 10:26 AM. Reason: solved

  2. #2
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: copying files from one location into another.

    We're starting with this code as it identifies the correct cells and the correct locations:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: copying files from one location into another.

    this suffices:

    Please Login or Register  to view this content.



  4. #4
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: copying files from one location into another.

    Thanks SNB! I'll have to try that as well. Looks like some compact code there.

    I found another solution, replaced the Name fucntion with the FileCopy function. Seems to work perfectly, and I understand it

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: copying files from one location into another.

    Having new issues with an error code "run-time error '53': File not found". It's calling out the line with the FileCopy function on the debug.


    Ran a check on a sample of data and all files and folders are there, the functions are calling out valid locations I also added code to check for the destination folder and create it if it isn't there.


    Please Login or Register  to view this content.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: copying files from one location into another.

    Use VBA's builtin facilities
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: copying files from one location into another.

    I've since tweaked this code, but can't get it to work again. Keep in mind this file and the data being sorted is on a local network on not on my machine. All file locations are entered as text strings and not formulas of some sort.

    I get a "path does not exist" error on the FSOobj.CreateFolder NewPath, but it's supposed to be creating a path based on the text string in column I.

    Please Login or Register  to view this content.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: copying files from one location into another.

    Here's a macro for creating all the folders and subfolders in a string path. There's a macro and a UDF version that other macros can use.
    Make Folders and Subfolders



    I added the UDF version of this code below your original macro, then called it to make your folders for you as needed.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 09-01-2011 at 12:39 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  9. #9
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: copying files from one location into another.

    Thanks, the MakeFolders function did exactly what I wanted it to.

+ 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