+ Reply to Thread
Results 1 to 21 of 21

Combine word documents in hyperlink list

  1. #1
    Registered User
    Join Date
    08-20-2020
    Location
    Milan
    MS-Off Ver
    2016
    Posts
    13

    Combine word documents in hyperlink list

    I am new in the world of VBA. I would look for help for my problem.

    I have list of file in range B3:40. In each cells, hyperlink to specific word document (.docx) file in the communal server.
    Now, I would like to combine all documents in the hyperlink list in that range become one new document that contain all documents in the list using VBA excel.

    Below is my code. I just can open it, but don't know how to combine it.

    Thank you in advance for any help.


    Please Login or Register  to view this content.
    Last edited by mattmar; 08-24-2020 at 03:53 AM.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Merge word documents in hyperlink list

    are you looking to use word's mail merge functionality? if that's what you're asking for, I put together an example that uses ms access a long time ago. you can do the exact same thing with excel. see the attached archive. let us know if it helps you out.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-20-2020
    Location
    Milan
    MS-Off Ver
    2016
    Posts
    13

    Re: Merge word documents in hyperlink list

    Quote Originally Posted by vba_php View Post
    are you looking to use word's mail merge functionality? if that's what you're asking for, I put together an example that uses ms access a long time ago. you can do the exact same thing with excel. see the attached archive. let us know if it helps you out.
    Hi vba_php,

    thank you for your response. Unfortunately I am not using this mail merge function. Maybe the better terms is combine instead of merge, because I would like to combine all the documents in the hyperlink list to become one new document that contain all document in the list.

  4. #4
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Combine word documents in hyperlink list

    ok, sorry to offer something of no value. so, if you want to combine the CONTENT in every word document into one full master document, the only thing I can really think of is just to use the COPY function in code to do it. but you know, you really haven't given people any clue as to what kind of content is in these documents. and furthermore, how you want the output to look. the one thing that is true for you at this point, and always will be, is that word has what is called an object model associated with it, just like every program in the world does. Objects are the basis of coding in any language, manufactured by every corporation in the world. so, how similar are all of these documents? and if they are similar, I assume you are simply wanting to take content of doc ''1'', paste it into the top of the master doc, then take content from doc ''2'', paste it into the master doc below content for doc ''1'', and on and on, etc....??

  5. #5
    Registered User
    Join Date
    08-20-2020
    Location
    Milan
    MS-Off Ver
    2016
    Posts
    13

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by vba_php View Post
    ok, sorry to offer something of no value. so, if you want to combine the CONTENT in every word document into one full master document, the only thing I can really think of is just to use the COPY function in code to do it. but you know, you really haven't given people any clue as to what kind of content is in these documents. and furthermore, how you want the output to look. the one thing that is true for you at this point, and always will be, is that word has what is called an object model associated with it, just like every program in the world does. Objects are the basis of coding in any language, manufactured by every corporation in the world. so, how similar are all of these documents? and if they are similar, I assume you are simply wanting to take content of doc ''1'', paste it into the top of the master doc, then take content from doc ''2'', paste it into the master doc below content for doc ''1'', and on and on, etc....??
    Hi vba_php

    I don't know if this will help you

    I have a list of word document in excel in range B3:B40. I would like to copy the document in the list and paste to a new document without changing the page format.

    I tried this code

    Please Login or Register  to view this content.
    But it give me "run time error 13".
    Last edited by mattmar; 08-24-2020 at 06:41 AM.

  6. #6
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by mattmar View Post
    Hi vba_php

    I don't know if this will help you
    I just want to clarify. I am not needing help. you are. (just kidding, sort of). I appreciate your words though. We are all here to help you, and obviously you have to help us help you.

    so, to the point....I ran the code you posted, which was this:
    Please Login or Register  to view this content.
    and, based on what I saw by replicating exactly what I think you are doing on your end, the code will obviously break on this line:
    Please Login or Register  to view this content.
    because you are attempting to open a single word document object by referring to all of them at once. yeah, that won't work. so, here is something to get you started, which loops through all of the documents in a replicated excel range on my end, which consists of 6 cells only, one by one, and opening the word doc and then closing it, one by one. I have stripped all other code out for this test. that way, you can do that work on your own since you already had that code written anyway. let us know when you get stuck again:
    Please Login or Register  to view this content.
    Last edited by vba_php; 08-24-2020 at 08:18 AM.

  7. #7
    Registered User
    Join Date
    08-20-2020
    Location
    Milan
    MS-Off Ver
    2016
    Posts
    13

    Talking Re: Combine word documents in hyperlink list

    Quote Originally Posted by vba_php View Post
    I just want to clarify. I am not needing help. you are. (just kidding, sort of). I appreciate your words though. We are all here to help you, and obviously you have to help us help you.

    so, to the point....I ran the code you posted, which was this:
    Please Login or Register  to view this content.
    and, based on what I saw by replicating exactly what I think you are doing on your end, the code will obviously break on this line:
    Please Login or Register  to view this content.
    because you are attempting to open a single word document object by referring to all of them at once. yeah, that won't work. so, here is something to get you started, which loops through all of the documents in a replicated excel range on my end, which consists of 6 cells only, one by one, and opening the word doc and then closing it, one by one. I have stripped all other code out for this test. that way, you can do that work on your own since you already had that code written anyway. let us know when you get stuck again:
    Please Login or Register  to view this content.
    Hi,

    Really appreciate for your time and help.
    I already tried it, it give me "run time error 424".

    And for other option (In case I am not able to do this one, because I think I run out of time), instead of copy all the documents to the new document, I just simply copy the document in the list from the source folder to the destination folder. I already tried this code,

    Please Login or Register  to view this content.
    But I got two problem:
    1. It copy all the documents in the folder not just specific file in the list
    2. It wont work when I change the worksheet. (In the workbook there are multiple worksheet, range don't work)
    Last edited by mattmar; 08-24-2020 at 09:50 AM.

  8. #8
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Combine word documents in hyperlink list

    well if you ran the actual literal code that I posted for you of course it's going to give you an error because you probably don't have the same directory setup that I had set up when I ran the test. So tell me is that what you did? The example was basically to help guide you to do it yourself and maybe I made a mistake by assuming that you could do that. If so I apologize. So can you clarify all of that please?

  9. #9
    Registered User
    Join Date
    08-20-2020
    Location
    Milan
    MS-Off Ver
    2016
    Posts
    13

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by vba_php View Post
    well if you ran the actual literal code that I posted for you of course it's going to give you an error because you probably don't have the same directory setup that I had set up when I ran the test. So tell me is that what you did? The example was basically to help guide you to do it yourself and maybe I made a mistake by assuming that you could do that. If so I apologize. So can you clarify all of that please?
    I already change the directory to my local directory. It gave me run time error 424.

  10. #10
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Combine word documents in hyperlink list

    Well I'm willing to still assist you but just telling me the runtime error number doesn't really help sir. oh no what see! I called somebody else sir when I tell everybody else not to call me that sorry about that LOL. So... Can you post the entire code that you're trying to run? More than likely that would provide the most help to somebody like me to help you out to finish the project. Or it would provide help to anybody else looking at this as well

  11. #11
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Combine word documents in hyperlink list

    Also make sure to indicate which line of the code is causing the etror

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Combine word documents in hyperlink list

    Did you change Sheet1 to Sheet6 to match your current working code?
    Rory

  13. #13
    Registered User
    Join Date
    08-20-2020
    Location
    Milan
    MS-Off Ver
    2016
    Posts
    13

    Re: Combine word documents in hyperlink list

    Dear all,

    Here is my actual code

    Please Login or Register  to view this content.
    Sorry for my lack of knowledge, really new in VBA. hehehe
    Thanks a lot for all help.

  14. #14
    Registered User
    Join Date
    08-20-2020
    Location
    Milan
    MS-Off Ver
    2016
    Posts
    13

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by rorya View Post
    Did you change Sheet1 to Sheet6 to match your current working code?
    Yes I do, because the document list is in sheet6

  15. #15
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Combine word documents in hyperlink list

    A couple of minor things:

    1. You should presumably be using objtempword, not objword, in that line.
    2. You don't need to append another backslash to the Folderpath variable as it already ends in one.
    (and 3, obviously that code doesn't actually do anything useful at this stage)

  16. #16
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by rorya View Post
    2. You don't need to append another backslash to the Folderpath variable as it already ends in one.
    obviously that is causing the error then.

  17. #17
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Combine word documents in hyperlink list

    Not necessarily - it was actually ignored in my tests, and it shouldn't produce that error anyway (it should be some sort of 'file not found' error).

  18. #18
    Registered User
    Join Date
    08-20-2020
    Location
    Milan
    MS-Off Ver
    2016
    Posts
    13

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by rorya View Post
    A couple of minor things:

    1. You should presumably be using objtempword, not objword, in that line.
    2. You don't need to append another backslash to the Folderpath variable as it already ends in one.
    (and 3, obviously that code doesn't actually do anything useful at this stage)
    I already did what you suggested, but it just give me blank word document

  19. #19
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by mattmar View Post
    I already did what you suggested, but it just give me blank word document
    it is supposed to give you a blank document. the code you provided initially in your original post does that very thing. are you looking for someone to write you addition to your original code so you can get done what you wish?

  20. #20
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,912

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by mattmar View Post
    I already did what you suggested, but it just give me blank word document
    Quite - note my point 3. All the code currently does is open and close a load of documents.

  21. #21
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Combine word documents in hyperlink list

    Quote Originally Posted by rorya View Post
    Quite - note my point 3. All the code currently does is open and close a load of documents.
    on purpose. hence, my last question to you mattmar.

+ 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. Hyperlink the word documents saved in a folder
    By buvanamali in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-14-2019, 02:47 AM
  2. Macro - Word Mail Merge into separate documents as PDF's
    By tanjasimono in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2017, 08:51 PM
  3. Replies: 2
    Last Post: 02-02-2016, 05:15 AM
  4. Macro to merge Excel information and Word documents?
    By danb1985 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-25-2010, 06:14 PM
  5. How to merge excel and word documents
    By jacqueline in forum Excel General
    Replies: 1
    Last Post: 03-27-2006, 08:52 PM
  6. [SOLVED] can I merge documents in excel like I can in Word
    By kaykayIT in forum Excel General
    Replies: 3
    Last Post: 11-09-2005, 10:00 PM
  7. how do I use mail merge in excel for word documents
    By Lisa J Duffy in forum Excel General
    Replies: 1
    Last Post: 08-04-2005, 09:05 AM

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