+ Reply to Thread
Results 1 to 6 of 6

Application.displayalerts not changing

  1. #1
    Registered User
    Join Date
    09-05-2014
    Location
    Montreal
    MS-Off Ver
    2007
    Posts
    22

    Application.displayalerts not changing

    Hi

    I have written a code snippet to prevent Excel from asking if the user wants to save some workbook that is programmatically closed:

    Please Login or Register  to view this content.
    However, the displayalerts=false does not toggle the property when I check via the immediate window when debugging. And when I try to toggle it directly via the immediate window (still in debugging) it does work. I really don't see what could be wrong?

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Application.displayalerts not changing

    Can you not just close the workbooks without saving them with code and avoid the display/popup all together?
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    09-05-2014
    Location
    Montreal
    MS-Off Ver
    2007
    Posts
    22

    Re: Application.displayalerts not changing

    In this particular case the workbook that is being closed has a routine in it workbook_beforeclose event where it is saved so I can't. Moreover I really don't see why the property is not changed by the command.

  4. #4
    Registered User
    Join Date
    03-26-2014
    Location
    Nowhere, somewhere
    MS-Off Ver
    Excel 2007
    Posts
    75

    Re: Application.displayalerts not changing

    Quote Originally Posted by ggs22 View Post
    I really don't see what could be wrong?
    Nothing is going wrong. This is just a consequence of working in the Immediate Window. When you issue the command "?Application.DisplayAlerts" it toggles to True, but reverts back once you resume your code unless you explicitly set it in the Immediate Window. I believe this is necessary so that you are notified of errors that occur in the Immediate Window.

    Give this try:
    Please Login or Register  to view this content.
    Select "Application.DisplayAlerts" and right-click on it and select "Add Watch". Now step through the code by pressing the F8 key and observe the watch window.

    Edit:
    If you want to Close the WorkBook without saving:
    Please Login or Register  to view this content.
    No need to worry about prompts to save and the BeforeClose event handler still runs.
    Last edited by TnTinMN; 05-14-2015 at 05:44 PM.

  5. #5
    Registered User
    Join Date
    09-05-2014
    Location
    Montreal
    MS-Off Ver
    2007
    Posts
    22

    Re: Application.displayalerts not changing

    Please Login or Register  to view this content.
    did the job thanks! Although I still don't understand the application.displayalerts behavior in this case, I'll make some experiments today.

  6. #6
    Registered User
    Join Date
    09-05-2014
    Location
    Montreal
    MS-Off Ver
    2007
    Posts
    22

    Re: Application.displayalerts not changing

    Please Login or Register  to view this content.
    did the job thanks! Although I still don't understand the application.displayalerts behavior in this case, I'll make some experiments today.

+ 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. Application.Displayalerts not working...
    By rbon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2015, 11:48 PM
  2. [SOLVED] Application.DisplayAlerts !
    By ks1102 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2013, 04:51 AM
  3. Application.DisplayAlerts not working
    By yogesh thakker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2010, 05:07 AM
  4. Application.DisplayAlerts = False
    By Jim May in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-18-2006, 12:35 PM
  5. [SOLVED] Application.DisplayAlerts
    By TK in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2005, 04:06 PM

Tags for this Thread

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