Results 1 to 7 of 7

Thread: [RESOLVED] Excel: eliminate warning about saving changes?

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [RESOLVED] Excel: eliminate warning about saving changes?

    I have an Excel spreadsheet in a web site. It is write-protected but changes are automatically made because of date/time-related functions. Is it possible to configurate it such that it won't ask about saving changes when it is closed?.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Excel: eliminate warning about saving changes?

    I think something like this would work
    VB Code:
    1. xl.Application.DisplayAlerts = False

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Excel: eliminate warning about saving changes?

    Quote Originally Posted by Hack
    I think something like this would work
    VB Code:
    1. xl.Application.DisplayAlerts = False
    It didn't work. Am I doing it right?
    VB Code:
    1. Private Sub Workbook_Open()
    2.     Application.DisplayAlerts = False
    3. End Sub
    I tried to place it in the procedures Workbook_Deactivate and Workbook_BeforeClose as well to no avail.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  4. #4

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Excel: eliminate warning about saving changes?

    For now I can make do with this, though it's not too elegant -kind of makes me feel like I'm cheating
    VB Code:
    1. Sub Workbook_BeforeClose()
    2.    SendKeys vbTab
    3.    SendKeys vbCr
    4. End Sub
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Excel: eliminate warning about saving changes?

    If you mark the workbook as already being saved then when its closed it wont prompt you to save it. This will work.
    VB Code:
    1. Sub Workbook_BeforeClose(Cancel As Boolean)
    2.     ActiveWorkbook.Saved = True
    3. End Sub
    Moved from General PC forum.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Excel: eliminate warning about saving changes?

    Quote Originally Posted by RobDog888
    [color=navy]Moved from General PC forum.
    Thank you sir!

    Nice little tip as well!

    BTW: In Access, to accomplish this you would do
    VB Code:
    1. Axs.DoCmd.SetWarnings = False
    Is there a handy dandy way of fooling Access as you have demonstrated can be done with Excel?

  7. #7

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Excel: eliminate warning about saving changes?

    Quote Originally Posted by RobDog888
    If you mark the workbook as already being saved then when its closed it wont prompt you to save it. This will work.
    VB Code:
    1. Sub Workbook_BeforeClose(Cancel As Boolean)
    2.     ActiveWorkbook.Saved = True
    3. End Sub
    Moved from General PC forum.
    Oh yes, sir, it does work! Thanks a lot. And btw I hadn't even noticed there was an Office Development Forum
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

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



Click Here to Expand Forum to Full Width