+ Reply to Thread
Results 1 to 10 of 10

Closing the workbook & saving automatically

  1. #1
    Registered User
    Join Date
    06-08-2005
    Posts
    67

    Closing the workbook & saving automatically

    I have my Excel workbook open & have made changes. Now I close it and Excel prompts me if I want to save the changes. Is there a way to just close the workbook and automatically accept any changes without have the "Do you want to save changes" message appear?

    What about if it is opened in read-only mode? Typically the workbook will not save any changes unless you save it off as another file name. If there is a solution to my question above, can it be enabled only when the workbook is opened in edit mode, or will it not auto-save changes over the file because Excel knows it was opened in read-only mode?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I don't think you can save changes in Read Only.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493
    Once the workbook has been saved you can use this, it goes into the workbook module
    Please Login or Register  to view this content.
    You can set up the workbook to be read only in the tools options, and then use a password if you want to modify the workbook....
    Last edited by davesexcel; 01-25-2008 at 11:59 AM.

  4. #4
    Registered User
    Join Date
    06-08-2005
    Posts
    67
    Sorry...the above still displays the "Do you want to save your changes" message when I try to close the workbook.

    I tried using the same thisworkbook.saved = true

    in the auto_close macro, but it did not save any changes I made to the workbook.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try


    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-08-2005
    Posts
    67
    Still get the "Do you want to save your changes" message. If I add

    Please Login or Register  to view this content.
    to the workbookbeforeclose macro, I still get the message.

    Just noticed something...these macros are contained on my sheet object. Do they need to be on my workbook object instead?
    Last edited by VBA Noob; 01-25-2008 at 02:41 PM.

  7. #7
    Registered User
    Join Date
    06-08-2005
    Posts
    67
    Got it working mostly with...

    Please Login or Register  to view this content.
    When opened in read-only mode, if someone tried to make a change, it closes without saving the changes.
    Last edited by VBA Noob; 01-25-2008 at 02:42 PM.

  8. #8
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    mwc0914,

    Please remember to wrap code next time. See forum rule 5 below to see how to wrap

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493
    I wonder if you have placed the code in the workbook module.....

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You shouldn't get the message with the code i supplied. I think Dave is right, you have put the code in the wrong place see the link in my signature for where to put the code.

+ 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