Results 1 to 6 of 6
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Make 1 doc out of many! (Word 2003)

    I have about 50 small documents (never counted them!) that I want to merge into one big document!
    Does someone out there have some existing code that I can use to do the job! I could try to work on some code, but why re-invent the wheel if there is already something out there I can use!

    1. I will need the code to open a document in a directory on the C: drive. (All the files are in this dir)
    2. Select and copy all the info
    3. Paste it into a document (at the end of all current text) called "Compiled Data", (also in the above directory)
    4. Close the source document and open the next document and repeat the process until all the files are copied.

    Is there a macro out there to do this task!

    Much appreciated if someone can help! <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Regards,
    Rudi

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Make 1 doc out of many! (Word 2003)

    Hi Rudi,

    You could use a series of INCLUDETEXT fields for this. 50 might take a bit of effort to set up, but they would then allow your compiled document to update semi-automatically any time the content of the source files change.

    You also wouldn't have to worry about any extraneous files being put in the same folder.

    To create an INCLUDETEXT field, press Ctrl-F9 to create a pair of field braces '{ }'. Then, type INCLUDETEXT and the path & name of the source file into the field, thus:
    {INCLUDETEXT "C:My DocumentsMy File.doc" !}
    Note the use of double backslashes for path separators. Then press F9 to see the result. Shift-F9 toggles the field code display on/off. For other files, just copy the field and change the filename.

    See Word's help file for more details.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Make 1 doc out of many! (Word 2003)

    Thanx 4 your reply macropod, but I do not need a linking scenario. This is a once off task to get all text in other docs into one doc. As you mentioned, doing this with a field or any other method will take some time, so I'm simply after a macro that will automate the task once off. <img src=/S/please.gif border=0 alt=please width=31 height=23>
    Regards,
    Rudi

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Make 1 doc out of many! (Word 2003)

    In that case, you need a macro that loops through all (Word) files in a folder copies their contents and pastes the copied material into the target document. Hans provided you with a macro to loop through a folder's files in <post#=400599>post 400599</post#>. Although for Excel, the process is essentially the same in Word. For a Word macro that loops through all (Word) files in a folder, see <post#=342610>post 342610</post#>. From there you only need to add your copy & paste routine (which the macro recorder will help you out with), and decide where to paste each file's contents.

    Also, I have no idea whether the required paste order will be the same as the order in which the files will be processed. If there is any doubt about this, you might be better off placing all the filenames into an array sorted into the required order, rather than simply looping through all files in whatever order they appear.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Make 1 doc out of many! (Word 2003)

    Thanks Macropod...that more what I'm after...I'm sure I could complete the copy and paste part as you said.
    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Regards,
    Rudi

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Make 1 doc out of many! (Word 2003)

    If INCLUDETEXT fields are otherwise convenient (I don't know, don't use them), then can be locked down to their present contents using the usual Ctrl+A (select entire document) Ctrl+Shift+F9 (unlink selected fields) trick.

Posting Permissions

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