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, 2021, and Excel in Microsoft 365


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, 2021, and Excel in Microsoft 365.

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

Inserting a Document's Location

Once you save a document on disk, it is stored in a particular folder (or location) on that disk. You may want that ...

Discover More

Using Drag-and-Drop to Create a Hyperlink

If you open workbooks in two instances of Excel, you can use drag-and-drop techniques to create hyperlinks from one ...

Discover More

Using the TRUNC Worksheet Function

Want to chop off everything after a certain point in a number? The TRUNC function can help with this need.

Discover More

Best-Selling VBA Tutorial for Beginners Take your Excel knowledge to the next level. With a little background in VBA programming, you can go well beyond basic spreadsheets and functions. Use macros to reduce errors, save time, and integrate with other Microsoft applications. Fully updated for the latest version of Office 365. Check out Microsoft 365 Excel VBA Programming For Dummies today!

More ExcelTips (ribbon)

Saving Changes when Closing

If your macro closes workbooks, you'll want to make sure that it will save any changes you made to the workbook. Here's ...

Discover More

Executing a Macro Every 15 Minutes

Need to run a macro at a given interval? It's easy to do when you learn how to use the .OnTime method, described in this tip.

Discover More

Checking the Scope of a Defined Name

When creating a macro to work with the names of defined ranges, you may need to know whether the scope of the name is for ...

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 three less than 9?

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.