+ Reply to Thread
Results 1 to 9 of 9

Close workbook if autosave is off

  1. #1
    Registered User
    Join Date
    08-04-2020
    Location
    Copenhagen, Denmark
    MS-Off Ver
    365
    Posts
    59

    Close workbook if autosave is off

    Hi

    I have an multiuser excel workbbook, with autosave set to "ON" as default.


    I wan't the workbook to close if autosave is set to "OFF"


    Please Login or Register  to view this content.
    How can I make this code work?

  2. #2
    Registered User
    Join Date
    05-12-2021
    Location
    Europe
    MS-Off Ver
    365
    Posts
    45

    Re: Close workbook if autosave is off

    I didnt find a proprierty to check for autosave.
    Try this code, this will close the workbook if it is not saved.
    Since the first time you open a workbook it is not saved, if you set this when the workbook is opened it will close it.
    Please Login or Register  to view this content.
    "Good Morning, Good Evening and Good Night"

  3. #3
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,542

    Re: Close workbook if autosave is off

    In Thisworkbook module
    Please Login or Register  to view this content.
    Artik

  4. #4
    Registered User
    Join Date
    08-04-2020
    Location
    Copenhagen, Denmark
    MS-Off Ver
    365
    Posts
    59

    Re: Close workbook if autosave is off

    Thank you

    It should work all time workbook is open, not before close?

    I have used the code in a timer, but in only works on start up, not if workbook is already open.
    (Timer on workbook open, starting code in module, looping the code every 5 sec)

  5. #5
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,542

    Re: Close workbook if autosave is off

    From the first post, I understood that you do not want to allow the closure of the Workbook when AutoSave is OFF. In contrast, from the last post, it appears that you want to make the AutoSave switch always be ON. Now I don't know exactly what you care about.

    Artik

  6. #6
    Registered User
    Join Date
    08-04-2020
    Location
    Copenhagen, Denmark
    MS-Off Ver
    365
    Posts
    59

    Re: Close workbook if autosave is off

    Hi

    Thank you for your answer.

    I want the workbook to close, if someone set the autosave to off

    Regards

    Tony

  7. #7
    Forum Contributor
    Join Date
    01-02-2020
    Location
    Idaho, USA
    MS-Off Ver
    365
    Posts
    274

    Re: Close workbook if autosave is off

    Here is a couple different bits of code that will close the workbook. The first 1 only saves then closes the workbook. The second one saves the workbooks, then closes Excel. This code needs to be put in the Workbook_SheetSelectionChange event, not the Worksheet_SelectionChange event, (although that would work too, but would only apply to that sheet and not the entire workbook. It would still require the user to click into any cell for it to close, but it works. If you want to go back to putting it into a timer routine, that would work too.

    So here's the 2 codes:

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-02-2020
    Location
    Idaho, USA
    MS-Off Ver
    365
    Posts
    274

    Re: Close workbook if autosave is off

    Also, here's a sample file in case that helps. Click on any cell and it will close if Autosave is off.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-04-2020
    Location
    Copenhagen, Denmark
    MS-Off Ver
    365
    Posts
    59

    Re: Close workbook if autosave is off

    Thank you for the answer

+ 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. Copy from first workbook, close open new workbook paste close
    By johncarr1952 in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 08-04-2021, 08:50 AM
  2. Autosave and close error
    By krishnaa_kumarr88 in forum Excel General
    Replies: 0
    Last Post: 11-03-2014, 10:47 AM
  3. Autosave/close gone horribly wrong - where to place code?
    By Greed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2012, 10:07 AM
  4. AutoSave on Close excel 2007
    By CrazyHorse in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-26-2011, 12:10 PM
  5. AutoSave before close
    By mattsvai in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2006, 11:16 AM
  6. [SOLVED] Opened Autosave but when closing workbook Autosave closes itself
    By Ken in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-29-2005, 01:05 PM
  7. autosave before close
    By J_J in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2005, 11:06 AM

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