+ Reply to Thread
Results 1 to 3 of 3

Need a batch file or VBA code to copy and rename a set of workbooks

  1. #1
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Need a batch file or VBA code to copy and rename a set of workbooks

    Please can someone help me produce a batch file or VBA module for automated copying and renaming?

    I have a project that I've been working on in work, and it's in the testing process. There will be some feedback coming my way soon, and I'll have to make some small changes.

    In each office folder (of which there are 12), I have 7 workbooks. Each office's folder contains the same set of workbook files. The VBA code is the same in every copy of each workbook, so it relies on the filenames being the same as the folder name.

    So for example, in the "LIL LIVERPOOL LEGAL" folder there are these files:

    1 - TUE - TRANSFERS IN - LIL LIVERPOOL LEGAL.xlsm
    2 - WED - TRANSFERS IN - LIL LIVERPOOL LEGAL.xlsm
    3 - THU - TRANSFERS IN - LIL LIVERPOOL LEGAL.xlsm
    4 - FRI - TRANSFERS IN - LIL LIVERPOOL LEGAL.xlsm
    5 - MON - TRANSFERS IN - LIL LIVERPOOL LEGAL.xlsm
    LIL LIVERPOOL LEGAL - TRANSFERS IN - WEEK SUMMARY.xlsm
    LIL LIVERPOOL LEGAL - TRANSFERS OUT.xlsm

    When I update these files (be it VBA code, or the workbook layout, or both), I then want to be able to copy this set of files to the other 11 folders. But of course, all the files need their names changing to the folder they are being copied to.

    At home I have FileMenuTools, so I can copy the files to each folder, and then rename them all at once (not as fast as a batch file, but still faster than renaming them one by one!). But I can't install that at work.

    So assuming I am prepared to specify the names of all of the folders when I want the files to be copied to (and then have their filenames changed based on the names above, and the containing folder), what batch file or VBA code would I need?

    Edit: Thinking about it, although I would prefer a batch file, it may be better if I used VBA code, because my computer in work might complain if I try to run a batch file and it doesn't know what it is.

  2. #2
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Re: Need a batch file or VBA code to copy and rename a set of workbooks

    I'm guessing the best way would be to store the current folder name in a variable, and then once the files had been copied to the new folder, search for that old folder name in each file name, and replace it with the new folder name. And I could copy and paste the code for each folder, because it doesn't need to have loops etc to make the code more "convenient". But I don't know how to do that via a batch file or via VBA.

  3. #3
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Re: Need a batch file or VBA code to copy and rename a set of workbooks

    Never mind I'm on my way to doing it myself now. Feel free to delete thread

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Code to copy range from 200 + workbooks and paste into one csv import file
    By CharlieMappley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2013, 10:41 AM
  2. Batch file & macro to copy the latest file from a folder
    By paidlukkha in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2013, 03:05 PM
  3. Batch Copy Certain Cells From Several Workbooks
    By exarranum in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2013, 05:12 AM
  4. Copy & rename sheets across multiple workbooks into one master.
    By CapnSef in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-25-2012, 03:58 AM
  5. [SOLVED] Want to run a DOS batch file (.bat) From Excel VBA code
    By Cazayoux in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2006, 05:48 PM

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