+ Reply to Thread
Results 1 to 3 of 3

Code to auto-answer a message box

  1. #1
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Code to auto-answer a message box

    I have a spreadsheet that emails a single sheet by creating a copy of the specific sheet and then emailing the copy. I wrote the code this way so that I could remove all the controls, buttons, etc from the sheet before sending. At the end of the macro, the code erases the created copy. Everything works fine but after Outlook spawns, I enter the email address and press 'Send'. It automatically returns to my workbook and continues the macro. This is where is erases the created copy of the sheet. At this time, the code stops and a message box pops up to request my approval to delete the created copy. My question: Is there a way I can avoid the message box, or have the code answer the message box with 'yes' (it's ok to delete) so that I don't have to actually click 'Yes' to continue the deletion? Basically I'm just looking for code to auto-answer the message box or simply keep it from popping up in the first place.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Code to auto-answer a message box

    Hi

    try

    Please Login or Register  to view this content.
    but don't forget to turn it back on again before the code finishes.

    rylo

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Code to auto-answer a message box

    Rylo, I totally agree with you re: resetting but DisplayAlerts will actually reset itself on completion of routine by default (including debugs)... it is one of those "odd ones" ... not coding the restore is a bad practice to get into IMO as the same is not true of the other "more important" Application level settings such as Events

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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