+ Reply to Thread
Results 1 to 23 of 23

Application.DisplayAlerts = False not setting

  1. #1
    Forum Contributor
    Join Date
    03-15-2016
    Location
    Vancouver, Canada
    MS-Off Ver
    w 10, Excel 2016
    Posts
    125

    Application.DisplayAlerts = False not setting

    Does anyone know of any setting where Application.DisplayAlerts could not be set? I've used this many times before without a problem... but in a current module I have

    Please Login or Register  to view this content.
    If I hover over it immediately before execution of that line - it's True... If I hover over it immediately AFTER executing that line (with no errors) - it's still True.

    ???

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Application.DisplayAlerts = False not setting

    Aside from the hovering what is indicating that its not actually off? Is a specific alert still showing?

    Do you have multiple routines that all run as part of a sequence of macros? Its possible that someplace in that another routine is superseding this one and is setting it back to true?
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Application.DisplayAlerts = False not setting

    Like Screenupdating, DisplayAlerts does not turn off while stepping through code.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Forum Contributor
    Join Date
    03-15-2016
    Location
    Vancouver, Canada
    MS-Off Ver
    w 10, Excel 2016
    Posts
    125

    Re: Application.DisplayAlerts = False not setting

    Thanks Zer0Cool and xlnitwit.

    I hadn't known that DisplayAlerts does not turn off while stepping through code. I have a routine below that closes up stuff... the challenge is it is still showing the "Save file" alert window when closing files (4th line below DisplayAlerts = False)

    Please Login or Register  to view this content.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Application.DisplayAlerts = False not setting

    Do you have any workbooks open that have never been saved?

  6. #6
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Application.DisplayAlerts = False not setting

    Edit: 31 Jan I expect I did not have my facts quite right here: I have tried to clarify a bit better in post #23



    Hi Andrew ( and Don and Zer0Cool )
    I notice that Screenupdating=False does not turn that off for me in debug F8 mode, but DisplayAlerts=False seems to turn Display alerts off in Debug F8 for me.. ??


    Anyway..
    Possibly what pops up is not a display alert?
    Possibly what is popping up is caused by
    ________ SaveChanges:=True
    Maybe if your file has changed, and then you are telling it to save any changes , then generally that will then want to save as you have made changes and so in that case of a change, it will cause the pop up thingy to come up to ask where to save. It is asking for the info to do what you asked it to do. It is not warning you.
    I do not know if that is correct. It is just a guess from me.

    But something like this seems to work for me , ..here I save before closing, so then don’t need to close with option SaveChanges:=True

    In this code I don’t get any warning with Application.DisplayAlerts = False, or Application.DisplayAlerts = True
    There is nothing to warn me of

    Please Login or Register  to view this content.
    Alan


    Edit: Morning Don, I had not seen your last post as I posted
    Last edited by Doc.AElstein; 01-31-2018 at 06:46 AM. Reason: Morning Don .... then later a tipoo
    '_- Google first, like this _ site:ExcelForum.com Gamut
    Use Code Tags: Highlight code; click on the # icon above,
    Post screenshots COPYABLE to a Spredsheet; NOT IMAGES PLEASE
    http://www.excelforum.com/the-water-...ml#post4109080
    https://app.box.com/s/gjpa8mk8ko4vkwcke3ig2w8z2wkfvrtv
    http://excelmatters.com/excel-forums/ ( Scrolll down to bottom )

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Application.DisplayAlerts = False not setting

    Quote Originally Posted by Doc.AElstein View Post
    I notice that Screenupdating=False does not turn that off for me in debug F8 mode, but DisplayAlerts=False seems to turn Display alerts off.. ??
    I've just done some more testing and it is a mixed bag! After setting it to False in debug mode, a
    Please Login or Register  to view this content.
    does return False, but hovering over it returns True and examining the property in the Locals window also shows True. However, more importantly, it does suppress alerts for me!

    But something like this seems to work for me , ..here I save before closing, so then don’t need to close with option SaveChanges:=True
    Those are functionally equivalent.

    Edit: Morning Don, I had not seen your last post as I posted
    Morning!

  8. #8
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Application.DisplayAlerts = False not setting

    I also see that weird seeming contradiction_ …. For example here:
    Please Login or Register  to view this content.
    _....... between
    in the ImmediteWindow,
    True
    True
    False

    and hovering over the Application.DisplayANerds:
    ApplicationDisplayAlertsTrueFalseImmediteWindow.JPG https://imgur.com/G80BEkC
    ( I hovered over the last of 5 Application.DisplayANerds to get that small bar )

    I’ll just have to make a note about that it “Suppresses” them … maybe there is some subtle difference between turned off and suppressed.
    ( I also get the same results in The immediate Window in normal F5 run or debug F8 mode )

    But note: In the watch window I also get the expected
    True
    True
    False

    ApplicationDisplayAlertsTrueFalseWatchWindow.JPG https://imgur.com/21N0fVp
    So by me it does display False when I expect it to

    So it is just the hovering over thing that seems a bit screwy by me, that is to say displaying True when I expect False when I hover over it.
    Maybe it is another broke thing
    Never mind

  9. #9
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Application.DisplayAlerts = False not setting

    ( I also note that it always starts telling me it is True everywhere , even if I had left it at False in the last code. Weird . It tells me that also for Application.ScreenUpdating --- but I know that in the practice if I leave it at False then my screen is usually dead.
    _.. so looks like you can’t really rely on all this stuff. Always best to experiment.. )

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Application.DisplayAlerts = False not setting

    Quote Originally Posted by Doc.AElstein View Post
    maybe there is some subtle difference between turned off and suppressed.
    DisplayAlerts simply applies the default option in any dialog box.

    But note: In the watch window [B]I also get the expected
    I think the watch window is closer to a Debug.Print than the Locals window (the watch window can actually affect your code).

  11. #11
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Application Boolean Locks .Boo locks. Certainly a lot of Boolox Is this True or Not - Wot

    Ah, glad you came back … I was actually mixing up locals and watch window. ..

    So I had a look at the Local Window to complete the set.
    Please Login or Register  to view this content.
    But I am still seeing in my Boolox the correct expected sequence
    True
    True
    False

    ApplicationDisplayAlertsImmediteWachLokal.JPG https://imgur.com/7KYbWW1

    I have never used the local window before, so possibly I am not looking at the Application.DisplayAlerts as I should and can. Possibly my Boolox is a load of Bollox.

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Application.DisplayAlerts = False not setting

    Interesting. I simply assigned the Application object to a variable and then watched its properties in the Locals window.

  13. #13
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Application.DisplayAlerts = False not setting

    I have the code in a Worksheet code Module…
    I just clicked on the _ + _ next to a _ Me _ in the Lokal Window
    I found _ Me _ CustomProperties _ Application _ DisplayAlerts
    DisplayAlertsInMe.JPG https://imgur.com/zDVztXJ
    I also then see a _ True _ after the passing of _ Application.DisplayAlerts = False _ in my code.


    Someone who seemed to know what they were talking about at the time once said to me something about _ Application _ related stuff being Binded differently , effectively Late or Early.. but I don’t really know what I am talking about and there is probably no relevance here…
    ( I do know about lLate and Early Binding, but I am just making a wild uneducated guess that there might be some relevance to the discrepancies here. . .. maybe my use of my BooLox did something later that looking in the local Application stuff window did does do or whatever … but I am just waffling rubbish… )






    https://www.mrexcel.com/forum/excel-...ml#post3990991
    Last edited by Doc.AElstein; 01-30-2018 at 06:33 AM.

  14. #14
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Application.DisplayAlerts = False not setting

    I had a quick look at that link but don't see how it relates to any of this? It mentions generic Objects being late bound, not the Application object.

    Having said that, it is true that the Excel.Application COM interface is essentially late bound since it is marked as extensible. That's why you can write something like
    Please Login or Register  to view this content.
    and the compiler won't complain- though you will of course get a 438 error at run time.

  15. #15
    Forum Contributor
    Join Date
    03-15-2016
    Location
    Vancouver, Canada
    MS-Off Ver
    w 10, Excel 2016
    Posts
    125

    Re: Application.DisplayAlerts = False not setting

    Hi all. Thanks for the great info... interesting stuff.

    Don you are right - the warning window appears on a wb that has not been saved - it's a scratch wb used temporarily. I didn't know that that would still put up a save window if DisplayAlerts was off on close. I just need to kill it off. To prevent the window - should I just save it and kill it?.

  16. #16
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Application.DisplayAlerts = False not setting

    If you have saved it then the window (to navigate to the place to save it) will not come up
    People usually advise not to use the Kill thing as that can be dangerous.
    Just delete the file later sometime manually is better practice, or just ignore it

    Edit
    or
    you can
    __Close_WB.Close SaveChanges:=False
    That will also not make that window come up - if it is a scrap workbook then you don't care if you save stuff or not?
    But if you are not saving then Excel won't want to ask you where to save it. '_.......

    “ “open” workbooks that aren’t
    '_...........You see what you actually have “open” in front of you is not the workbook that you think it is. It is not really any workbook at all. It is just something similar to a copy of the workbook that you think it is. That copy was made when you thought that you had “opened” it.
    It was not really opened. Just a copy of it was made and you are then looking at the copy.
    If you just close ( without saving SaveChanges:=False) then that copy is gone.
    ( The original Workbook stays as it was, or rather stays as it is, unchanged ( assuming you have not saved in the meantime) )
    If you save, then what actually happens is that at that point in time ( the time when you save ) the file at the specified place is updated from the copy in front of you.








    http://www.excelfox.com/forum/showth...-Name#post9949
    Last edited by Doc.AElstein; 01-31-2018 at 08:26 AM. Reason: Edit try SaveChanges:=False

  17. #17
    Forum Contributor
    Join Date
    03-15-2016
    Location
    Vancouver, Canada
    MS-Off Ver
    w 10, Excel 2016
    Posts
    125

    Re: Application.DisplayAlerts = False not setting

    Thanks Doc... The challenge is that CloseNClean sub is called from inside a loop that's doing a million other things... the sub just closes everything up at the end of the loop and other code inside the loop opens files as needed next time through. So this close sub doesn't really know whats files are open by name hence the "for each..." I have assumed that all files open need to be saved - hence the .SaveChanges :=True. The main procedure runs all day - so there might be a hundred or so TEMP Worbooks a day being used. So I'd really like to find a way to just junk them in the code without the code stopping and waiting for input - or having to manually delete them.

    Thanks again for your help. Here's the code again for reference.
    Please Login or Register  to view this content.

  18. #18
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Application.DisplayAlerts = False not setting

    Perhaps this
    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    03-15-2016
    Location
    Vancouver, Canada
    MS-Off Ver
    w 10, Excel 2016
    Posts
    125

    Re: Application.DisplayAlerts = False not setting

    Nice! I'll try that thanks!

  20. #20
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Application.DisplayAlerts = False not setting

    This seemed to work just now for me, but i do not have much experience with killing stuff
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor
    Join Date
    03-15-2016
    Location
    Vancouver, Canada
    MS-Off Ver
    w 10, Excel 2016
    Posts
    125

    Re: Application.DisplayAlerts = False not setting

    Thanks again Doc and Don. Don - your suggestion seems to work. You've both been so helpful as always. So very much appreciated. I've learned some new stuff from your posts today. Cheers!
    I'll mark this as closed now.

  22. #22
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Application.DisplayAlerts = False not setting

    You're welcome.

  23. #23
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Application.DisplayAlerts = False not setting. Delete all Temporary Open Workbook Files

    Hi Andrew, Hi Don
    Thanks Andrew for the Feedback, Rep and for Marking the Thread as [Solved] .

    A few follow up comments and possibly useful observations..mostly from Don’s last code..
    Please Login or Register  to view this content.
    _1) I expect I have ( or rather had **) missed the obvious again. I was not sure what Don’s last code is / was about. **In fact, in preparing this post , I think I may have twigged to what is going on.
    It might be helpful to me and maybe anyone else catching this thread if I try to elaborate a bit here just to make things a bit clearer about what is going on:
    If , as is the case, we looping for all your Kloss_WB , then just to remind us, we are looping for all “open” workbooks. Well actually not quite…..
    It all depends what you mean by “open” workbooks. Reading again myself what I wrote about that in the second half of post #16 about “ “open” workbooks that aren’t” , …. and then also I should have caught the meaning of this a bit better
    Quote Originally Posted by xlnitwit View Post
    Do you have any workbooks open that have never been saved?
    Quote Originally Posted by Andrew Entee View Post
    yes...the warning window appears on a wb that has not been saved -...
    You are looping for all the things masquerading as Workbooks in the imaginary world of your computer screen:

    You will have one or more of the following things masquerading as Workbooks:

    _(i) Copies of any existing files: The copies came into existence when you “opened” them.
    Never the less, Excel holds a .path for them. It holds the path of the actual Files of which they are copies.
    If you Close these “files” with either of the 3 variations possible ( Kloss_WB.Close SaveChanges:=False _ Kloss_WB.Close SaveChanges:=True _ Kloss_WB.Close ____ ) , then you will not get the Window to pop to ask where to save.
    If you use these two variations , which include either of the Optional two arguments ( Kloss_WB.Close SaveChanges:=False _ Kloss_WB.Close SaveChanges:=True _ ) you will not get the warning either asking you whether or not you want to save changes.
    If you Close using this option ( _ Kloss_WB.Close ____ ) then you may get the warning asking you to whether or not you want to save changes: You won’t get it if you have either not made any changes or have Saved after any changes.

    _(ii) You may have made some New Files. Or so you may have thought. If you thought you did, then you haven’t yet made those files. They will be made when you Save. Before you Save, these things do not have a .path.
    So Don’s last code snippet looks initially for the “files” of this (ii) type. As long as you include either of the Optional two arguments then you won’t get the warning asking you if you want to save changes. Also if you choose as Don did, the option , ( Kloss_WB.Close SaveChanges:=False ) , then no attempt is made to save. You have not deleted the file. It never existed. But it may appear that you have trashed a temporary workbook. I expect that is exactly what you, Andrew, wanted. Quite neat and well observed from Don actually.

    ( I actually got my facts not quite correct in post #6: I have put in an Edit to that effect in post #6 . I expect that I had “made some New files”, that is to say, made some of these (ii) things, but had not bothered to save them. They would have caused the window to come up asking for the path of where you wanted to save them. I mistakenly may have said that this occurs for the things of type (i). It doesn’t. )

    Note: that any other files that were not “Temporary files” but that you had “opened” are not deleted. But they are Saved, ( if they are not the file with the code in ) , by, and Closed by, Don’s code lines
    __Else
    ____Close_WB.Close SaveChanges:=True

    I expect that is exactly what you, Andrew, wanted


    _2) This is probably not relevant now, as Don has probably hit the nail on the head with what you actually wanted… but if you did want to delete all “open” files , then my last code was not quite correct because
    _a) I was assuming all files were in the Folder as the File with the code in it,
    _b) I had missed the subtle point that Don’s code brought up about “files” that are “open” that have no path as they do not exist anywhere.
    This would be my code now ( but I would never use it. I am sure in you use this code, then one day you want to Kill me because you unintentionally deleted without trace something important ):
    Please Login or Register  to view this content.

    _3) On the off chance that you did indeed want to delete all files “open” , those with and without a .path , then I would do it differently. I would make manually ( or create as part of my code ) a Folder , probably on my desktop with a name like “TemporayFileDump”
    I would then loop through and first save the File in that Folder, then Kill it in its original place if it had one ( Type (i) will have a place, Type (ii) wont )
    Once in a while I would trash the folder “TemporayFileDump”, or better still copy it to some cheap external file source adding a date to its name and then trash the folder on my desktop.

    ( I might be interested to do this option 3) for my own use sometime, … ( but I expect I will actually use Don’s code instead ) … if I do do it , I will drop a link to where I have the code in this Thread. )


    _4) This is not too important. It might be worth considering to change the title of this Thread to maybe like
    .. “.. Application.DisplayAlerts = False not setting. Delete all Temporary Open Workbook Files ….”…
    That way someone looking for this sort of a thing in a search might find better the useful information here
    ( Here are some notes on how to change a Thread title.. https://www.excelforum.com/developme...ml#post4592539 )
    Last edited by Doc.AElstein; 01-31-2018 at 11:58 AM.

+ 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. A bug which Inputs Application.DisplayAlerts = False As part of the spreadsheet
    By starlev in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-24-2014, 10:16 AM
  2. [SOLVED] Application.DisplayAlerts = False Doesn't work
    By Hiawatha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-20-2014, 11:15 AM
  3. setting displayalerts to false doesnt work
    By mekha in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-23-2014, 04:55 AM
  4. [SOLVED] Application.DisplayAlerts = False does not work
    By tryer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2013, 10:23 AM
  5. [SOLVED] Disable Run-Time Errors "Application.DisplayAlerts = False" Not Working
    By Punx in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-12-2012, 03:03 PM
  6. Application.DisplayAlerts = False showing True
    By SOS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2008, 06:36 AM
  7. Application.DisplayAlerts = False
    By Jim May in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-18-2006, 12:35 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