+ Reply to Thread
Results 1 to 19 of 19

How to copy a Word document 30 times and rename it

  1. #1
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    How to copy a Word document 30 times and rename it

    Scenario:
    I have a master document for writing a school report on a pupil.
    This needs to be duplicated for every student in the school and the file name needs to have the childs surname and first name on it.
    I can pull the surnames from the Management system in school into column A of Excel and forenames into column B.
    Is there a macro that can take the word document, copy it and rename it using data from column a and b and then replicate the process for each row in the spreadsheet?

    To future proof this sheet, it would be great if it could ask the user to select the file to be copied and then the folder that this will copy in to so that I can give this macro (embedded into Excel) to admin to run.

    Hope someone can help or I might have the files names by the times the students leave the school (7 years!)
    Last edited by Newbuilder; 08-06-2017 at 07:26 PM.

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

    Re: How to copy a Word document 30 times and rename it

    Will this be PCs only or some Mac as well, I mean all the computers running this?
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: How to copy a Word document 30 times and rename it

    Hi
    Thanks for the reply, this would be on Windows PC machines.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: How to copy a Word document 30 times and rename it

    What you're describing is a mailmerge. See: https://support.office.com/en-us/art...f-932c49474705
    No VBA programming is required for this.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: How to copy a Word document 30 times and rename it

    I am familiar with mail merge but did not know that it can copy a file 30x and then rename a file name 30 times using the names from a spreadsheet . I thought it only merged within the document

    So master report.docx will be copied to a destination folder then renamed as bloggs john report.docx

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

    Re: How to copy a Word document 30 times and rename it

    I read the question as an Excel VBA question.

    How to take a list of names in an Excel Spreadsheet and use those names to create named copies of a Word Document, selecting the template file to make copies and selecting the destination for the copies being created with the new names.

  7. #7
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: How to copy a Word document 30 times and rename it

    @JBeaucaire 👍

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: How to copy a Word document 30 times and rename it

    If you want to automate a mailmerge, to output separate documents instead of a single document (including giving the output documents names corresponding to fields in the source data), see Send Mailmerge Output to Individual Files in the Mailmerge Tips and Tricks threads at:
    http://www.msofficeforums.com/mail-m...ps-tricks.html
    or:
    http://windowssecrets.com/forums/sho...ips-amp-Tricks

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

    Re: How to copy a Word document 30 times and rename it

    This macro does what you've described, assuming the sheet name with the student names is called SHEET1, else you can change that in the code. With this macro you select any file to COPY and the select any destination folder.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 08-07-2017 at 12:25 AM.

  10. #10
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: How to copy a Word document 30 times and rename it

    This looks brilliant and I will test it out as soon as I return to work. Pushing my luck now but as all pupil names will come into the spreadsheet is there a way to say "put into folder named in column c"

    This will save us either copying and pasting each class and running the program or running it all then having to choose who should be in what class/form.

    Column c would contain the class name and there would be a folders set up with these names within the directory structures. Warning: we would still need the select destination to get tell it the parent directory and then column c would tell it the sub directory within this selected parent directory

    Thanks so much

  11. #11
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: How to copy a Word document 30 times and rename it

    Hi, it goes through all the prompts but doesn't do the copying and pasting of the new file.

    File uploaded to show you.
    PS. The copying and pasting of data will always create headers in Row 1 so it would be great if it could be amended to look from row 2. Don't worry if not, we just delete a file.
    Attached Files Attached Files

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

    Re: How to copy a Word document 30 times and rename it

    It works! Here's a video, I just opened your file and ran it...

    https://www.screencast.com/t/FOsNG0KDPK

  13. #13
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: How to copy a Word document 30 times and rename it

    Quote Originally Posted by JBeaucaire View Post
    It works! Here's a video, I just opened your file and ran it...

    https://www.screencast.com/t/FOsNG0KDPK
    So it does, must have not saved the file first after adding the data.

    This is absolutely amazing.


    I have managed to add a force save and pop up Success box.
    Last edited by Newbuilder; 08-07-2017 at 05:38 PM.

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

    Re: How to copy a Word document 30 times and rename it

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  15. #15
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: How to copy a Word document 30 times and rename it

    FWIW, the mailmerge approach can also populate the document with content from your worksheet (e.g. insert the student names) without the need for more code and, with a minor code change, save to different folders

  16. #16
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: How to copy a Word document 30 times and rename it

    I've Broken it, what have I done!
    It does not ask for file locations etc

    Capture.PNG

  17. #17
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to copy a Word document 30 times and rename it

    Goto Tools>References ...
    Are any items (libraries) marked as MISSING?

    If there are note their names, uncheck them, save the file, and close Excel.

    Now reopen the file and try the code again.
    If posting code please use code tags, see here.

  18. #18
    Registered User
    Join Date
    01-25-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    49

    Re: How to copy a Word document 30 times and rename it

    Can I get the order for Excel (2013) PC please I don't have a tools

  19. #19
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to copy a Word document 30 times and rename it

    It's in the VBE which you can open using ALT+F11.

+ 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. [SOLVED] VBA in Word, how to copy cells from a table into another word document that contentcontrol
    By reesjordan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2015, 04:39 AM
  2. Inserting a chart several times into a word document
    By Markc1001 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 04-12-2015, 10:44 AM
  3. Replies: 0
    Last Post: 09-04-2014, 03:32 AM
  4. Replies: 0
    Last Post: 06-28-2014, 02:26 PM
  5. copy a file several times, rename it and place in a specific folder
    By exceliscool in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2013, 07:35 AM
  6. Add text to Existing Word Document if it Doesn't exist create Word Document
    By unstable81 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-10-2013, 12:15 AM
  7. [SOLVED] Copy sheet to new file and rename 52 times one per week
    By Greaser2k in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2012, 03:53 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