+ Reply to Thread
Results 1 to 7 of 7

Email results in infinite loop

  1. #1
    Registered User
    Join Date
    12-27-2015
    Location
    Iowa, USA
    MS-Off Ver
    2010
    Posts
    83

    Email results in infinite loop

    Hi all,

    The following opens a new email and pastes an image, ("Group 1") into the body. Problem is, after the PasteAndFormat line, the code appears to restart instead of moving to the next line. Can someone explain why and how to fix this?

    HTML Code: 

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Email results in infinite loop

    .
    You can try placing a EXIT SUB in one of two areas as indicated below :

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Email results in infinite loop

    Hi there,

    If you're using the F8 key to step through your code, the routine will indeed appear to stop, because the yellow highlighted line will disappear as soon as the PasteAndFormat command has executed.

    However, by inserting the highlighted rows in the following code you will see that the routine does in fact complete its execution:

    Please Login or Register  to view this content.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  4. #4
    Registered User
    Join Date
    12-27-2015
    Location
    Iowa, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Email results in infinite loop

    Thanks guys for looking at this. As it turns out Greg was correct... I was stepping through with F8 and I was expecting it to step to the next, but instead it just started the sub over again. I mistook it for an infinite loop, i.e. I tricked myself. My sincere apologies for the time wasted to look at this.

    Lewis

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Email results in infinite loop

    Hi again,

    Many thanks for your feedback.

    No need for apologies - glad I was able to help.

    Regards,

    Greg M

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Email results in infinite loop

    .
    Glad you found your answer.

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Email results in infinite loop

    Hi again,

    Many thanks for the Reputation increase - much appreciated!

    Glad I was able to help.

    Best regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Infinite loop
    By madhatter40 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-26-2017, 07:53 PM
  2. [SOLVED] Email a range of excel cells using VBA produces infinite loop HELP
    By kjam in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 11-13-2015, 09:58 PM
  3. Infinite Loop
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2015, 07:56 AM
  4. Why is my loop infinite, and how can I fix it?
    By Mrowe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-13-2012, 02:48 PM
  5. Infinite Loop
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-12-2010, 10:44 PM
  6. Infinite Loop
    By phong919 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-22-2010, 04:56 PM
  7. For Next Infinite Loop
    By Naji in forum Excel General
    Replies: 5
    Last Post: 01-13-2006, 03:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1