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
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.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
As your macro is processing information, there will doubtless be times that it will need to compare information in ...
Discover MoreIf you develop some handy macros that you use on your system, you may want to share those macros with others. This tip ...
Discover MoreHaving macros in multiple open workbooks can sometimes produce unexpected or undesired results. If your macros are ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments