+ Reply to Thread
Results 1 to 6 of 6

Excel macro to merge word docs based on cell value

  1. #1
    Registered User
    Join Date
    11-05-2012
    Location
    Tamil nadu, India
    MS-Off Ver
    Excel 2007
    Posts
    7

    Question Excel macro to merge word docs based on cell value

    I have a number of word documents in one folder. I want to merge selected files out of them into a new word doc based on selection of the file names in an excel sheet. The macro has to read the file names i have selected and fetch the respective word docs and merge them in the order that can be controlled by me. The excel sheet may be in the same folder or in a different one. Please help. Thanks in advance.

    Srinath.

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Excel macro to merge word docs based on cell value

    Hi

    try this macro

    the file names are in the range FileRange in the excel sheet, and the Directory the files are in is set by FileDir



    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Excel macro to merge word docs based on cell value

    ... you will need to have the Microsoft Word object library checked in tools > references in your VBA area for this to work

  4. #4
    Registered User
    Join Date
    11-05-2012
    Location
    Tamil nadu, India
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Excel macro to merge word docs based on cell value

    Hi

    Thanks a lot for the code!

    It works perfectly... Only hitch is that it stops merging if there are blanks in between the file names..Can you just tell me how to modify the code so that it ignores blank spaces in the cell range that we give?

    Thanks in advance for your help!

    Quote Originally Posted by NickyC View Post
    Hi

    try this macro

    the file names are in the range FileRange in the excel sheet, and the Directory the files are in is set by FileDir



    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Excel macro to merge word docs based on cell value

    try this
    Please Login or Register  to view this content.
    Last edited by NickyC; 11-07-2012 at 02:48 AM. Reason: code tags

  6. #6
    Registered User
    Join Date
    11-05-2012
    Location
    Tamil nadu, India
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Excel macro to merge word docs based on cell value

    Hi

    Thanks a lot! Working just the way i want!

    Can i modify the macro to save the word doc with a name of my choice? The name can be preset, for eg. "projectname_yyyymmdd.doc".
    The location for saving can be by default the folder in which the excel sheet with the macro is saved. Or it has to ask where to save.

    Thanks in advance!
    Last edited by srinathtr; 11-07-2012 at 11:36 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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