E-mailing PDF Reports Results in Consistent Crash

Written by Allen Wyatt (last updated June 11, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


2

Frank uses a macro to create a personalized report in Excel. The macro then saves each personalized report as a PDF file. This successfully generates 350 PDF files. The macro then uses Outlook to e-mail those reports, one by one. The macro always stops after report 95, every time. If Frank changes the code so that it e-mails an XLSX file instead of the PDF file, then it sends all 350 with no problem. He is looking for ideas as to why e-mailing the 350 messages, with a PDF attachment, would consistently fail after 95 messages.

As is the case with many macros, without looking at the code and the data being manipulated, it is hard to offer the widest range of suggestions. There are a few things that you can look at, however.

First, there are reports that the Clipboard history can cause issues if your macro is doing a lot of copying and pasting. So, consider disabling the Clipboard history before running the macro.

Second, the fact that it stops at the same point every time would seem to indicate that there is something about that point that is causing the issue. Take a look at the 94th and 95th PDF files (yes, both) and see how large they are. It is possible that one or both are exceeding the size of attachments permissible either by Outlook or by your ISP. You can quickly determine this by moving those recipients to a later position in the processing order and seeing if your problem moves to the same point to which you moved them.

Finally, if the individual attachments are small enough, it is very possible that they are too large, in aggregate. It is a good bet that the PDF files are larger than the XLSX files. Since you are attaching larger files and e-mailing them, it is very possible that your macro is trying to move messages faster than they can be sent out by Outlook or accepted by your ISP. Try putting a delay—perhaps even a two-minute delay—after every 50 messages or so. That may give time for the bottleneck to clear before sending resumes. If that works, you could spread out the delay so that it is more even. For instance, you could put a three-second delay after every message is sent or a twenty-second delay after every ten messages. This will take some testing, but may alleviate the issue.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9596) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Calculating Week-Ending Dates

When working with dates, you may need to figure out all the dates on which weeks end in a given year. There are several ...

Discover More

Removing Fingernail Ridges

If you are trying to get the look of glamorous or sophisticated natural nails, you may be foiled in your attempts by ...

Discover More

Formatted Dates Appear Differently on Different Systems

When you format a date in a specific manner, you may be surprised to see that the format changes when you open the ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Making Common Functions Available to Others

When you use macros to create functions, you might want to share those functions with others�"particularly if they ...

Discover More

Making a Cell's Contents Italics within a Macro

You can use macros to process information in your worksheets. You may want to use that macro to apply the italic ...

Discover More

Excel Crashes when Running Macros

It can be frustrating when macros don't run as you expect. When it occurs, however, tracking down the cause can be even ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2022-06-13 13:14:20

Mike D.

I just remembered something similar to this where a mail system would not let more than a certain type of file to be sent by an individual within such a short period of time because it looked like SPAM. The culprit may be your email server. I realize the .xls files go through but that may be to that both programs are Microsoft and PDF is not.

One suggestion to the issue would be to try breaking up the “Send” into groups, say 1 to 80, then restart the macro at the next increment, 81 to 160. Send it in blocks, not the whole wall.

Another suggestion: send ‘one’ email to everyone but put that group in the Bcc: and your name in the To:. This way you are only sending one email and the server will handle the copies.

Best of luck,


2022-06-13 08:49:06

Bigjaker

I had the same issue quite some time ago and was doing the same process. I used the three second delay and it worked like a charm.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.