+ Reply to Thread
Results 1 to 2 of 2

Macro to automate Mail Merge timing-out

  1. #1
    Registered User
    Join Date
    07-29-2021
    Location
    Charleston, SC
    MS-Off Ver
    Microsoft Office 365
    Posts
    6

    Macro to automate Mail Merge timing-out

    Once a month, a colleague of mine uses a Mail Merge template I created to send out statements to all clients. He's less computer savvy than I am, and his lack of understanding is causing discomfort with him using that Mail Merge tool, but the alternative (manual entry) would be even more prone to human error and be far too time consuming. I've written a macro to automate the process of completing the Mail Merge - the idea is my colleague should be able to click a button from the workbook containing the data and not have to worry about following the step-by-step process or screwing it up again.

    The macro I wrote starts working fine, but then it fails in the middle of it, anywhere from record 120 to record 180 (out of around 200 total). I receive an error message on the .Execute command that completes the merge, and that error message is "Run-time error 5535: Word could not finish merging these documents or inserting this database." It is failing on a different record each time I test it, so I don't think it has anything to do with syntax. It seems to be timing out, and I'm not sure how to allow more time to complete the merge. An alternative would be to split it into two macros, with the first handling records 1-100 and the second one handling records 101+, but that is not ideal.

    Any advice would be much appreciated!

    -KF

    Please Login or Register  to view this content.
    Last edited by kpfoote811; 02-02-2023 at 12:19 PM.

  2. #2
    Registered User
    Join Date
    07-29-2021
    Location
    Charleston, SC
    MS-Off Ver
    Microsoft Office 365
    Posts
    6

    Re: Macro to automate Mail Merge timing-out

    I just figured it out. Posting this solution in case anyone else searches the same problem, because when I did, I was coming up with nothing.

    It occurred to me that the timing out might not be happening at the time the .Execute line runs, but beforehand when the datasource is being loaded into Word. I simply added "DoEvents" right before the .Execute line, and now it works like a charm.

    I suppose the reason it was erroring out on the .Execute line was because it was beginning before the source data was uploaded, causing the data to be cut short. Adding DoEvents before .Execute allows the macro to wait on the datasource upload to complete before proceeding with executing the merge.

    I hope this helps someone - had been struggling with this for a few days.

+ 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. VBA CODE to automate mail merge
    By Yolandivdberg2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2022, 05:30 PM
  2. Mail Merge - Create separate Mail merge pdf for each sheets of an excel file
    By sureshbvs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2021, 12:38 PM
  3. Replies: 5
    Last Post: 11-15-2018, 10:54 PM
  4. Mail Merge - Merge fields lister macro
    By adil.master in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2015, 10:33 AM
  5. Replies: 0
    Last Post: 01-05-2015, 07:35 AM
  6. Replies: 2
    Last Post: 07-12-2012, 08:11 PM
  7. How can I automate an e-mail to be send in macro?
    By john in forum Excel General
    Replies: 6
    Last Post: 01-25-2006, 04:45 PM

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