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

Printing the Active Document from a Macro

When you process a document in a macro, you may also want to print that document from within the same macro. Here's how ...

Discover More

Squaring Table Cells

Inserting a table is fast and easy in Word. You may want to make sure that the cells in the table are as square as ...

Discover More

Copying Print Areas when Copying Worksheets

Print areas are a great way to define what, exactly, you want to print from a worksheet. When you copy worksheets, the ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Stopping Excel from Deleting Macros from a Workbook

When working with very large workbooks, it is possible for Excel to behave erratically. This tip looks at ways you can ...

Discover More

Copying Pictures with a Macro

Copying information using a macro is rather simple, although there are multiple ways you can do the copying. The most ...

Discover More

Creating an Animated Count Up

You might want to display a value in a cell as an upward-counting value. This might seem difficult but can be done rather ...

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 2 + 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.