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

Making Bookmarks Bold

Do you want an easy way to see all the bookmarks in your document? Word provides a way to make them visible, or you can ...

Discover More

Changing European Dates to US Dates

Want to change the order of the day and month in a date? This tip shows you how you can do so using the Find and Replace ...

Discover More

Ignoring Special Characters when Double-Clicking

If a word contains a special character within it, Excel actually thinks the single word is two words. This tip examines ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Develop Macros in Their Own Workbook

If you develop macros and edit them quite a bit, you may be running the risk of causing problems with the macros or with ...

Discover More

Deriving an Absolute Value in a Macro

Need to figure out an absolute value within your macro code? It's easy to do using the Abs function, described in this tip.

Discover More

Swapping Two Strings

Strings are used quite frequently in macros. You may want to swap the contents of two string variables, and you can do so ...

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 8 + 8?

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.