+ Reply to Thread
Results 1 to 14 of 14

Undo all changes since open or last save

  1. #1
    Registered User
    Join Date
    01-31-2008
    MS-Off Ver
    2010
    Posts
    38

    Undo all changes since open or last save

    I have a spreadsheet that automatically saves itself when you close it (it doesn't prompt the user) as I must make several sheets hidden upon exit. I can't have it prompt the user the normal way as they may chose not to save and of course the sheet state wont then be saved on exit.

    My thinking is to setup a basic 'Do you want to save?' Yes/No form upon exit and have the user pick accordingly. If they chose Yes, then it just saves, easy ...If they pick No then it undoes everything modified on the spreadsheet since the last manual 'Save' (They may not have saved it, they may have just opened it and changed a few numbers here and there, both are possible)

    Looking at some of the 'undo' code on the internet I'm guessing it's not possible as you have to store every change in order to be able to change it back, right? Perhaps it's possible to somehow use 'SaveAs' and create a temporary copy and somehow revert back to the original one upon exit (if they choose No) ...I don't know I'm just thinking aloud I guess.

    If you have any thoughts or suggestions they are very welcome.

    Many thanks

    Brelin

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Undo all changes since open or last save

    Hi Brelin,

    If you don't save any changes when you close it does what I think you are wanting. No changes means that it will appear as it was opened last time. Are you overthinking this?

    Do you mean that you want to save the Hidden Sheets stuff but not the visible sheet stuff?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    01-31-2008
    MS-Off Ver
    2010
    Posts
    38

    Re: Undo all changes since open or last save

    Quote Originally Posted by MarvinP View Post
    Hi Brelin,

    If you don't save any changes when you close it does what I think you are wanting. No changes means that it will appear as it was opened last time. Are you overthinking this?

    Do you mean that you want to save the Hidden Sheets stuff but not the visible sheet stuff?
    After the close command runs I turn off visibility of certain sheets and then it does a force (no prompt) save to keep these changes for when it's next opened. However, if the user has opened it and played around with some numbers but doesn't want to save those changes then when they close it it'll just save them anyway due to my 'force save' ...not good. I need to be able to undo everything done by the user up to running the close command, if they wish it undone that is.

    I use the open command to turn on visibility of certain sheets (depending on who logs into it) ...so open turns certain ones on and close turns them off. I must have it save the visibility changes otherwise the next time you open it they will all be turned on defeating the object of hiding the sheets.

    Have I explained that a little better?
    Last edited by Brelin; 03-15-2011 at 06:05 PM.

  4. #4
    Registered User
    Join Date
    01-31-2008
    MS-Off Ver
    2010
    Posts
    38

    Re: Undo all changes since open or last save

    Does anyone have any thoughts or ideas on how to achieve this?

    Many thanks

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Undo all changes since open or last save

    Hi,
    How about a work-a-round? What if you added the current time and date to the filename? You would then be saving multiple files but you could tell when they were saved by the filename. This would be like doing progressive archiving.

  6. #6
    Registered User
    Join Date
    01-31-2008
    MS-Off Ver
    2010
    Posts
    38

    Re: Undo all changes since open or last save

    The thought had crossed my mind about that Marvin. However I can see that people could be going in and out of the file quite a lot (without making changes necessarily) and the result would be quite a few files in there before it's done with. The file is about 1MB so if I can avoid making multiple copies (that don't need to be there) I'd like to.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Undo all changes since open or last save

    Keep it simple: there's no need to hide sheets when closing if you hide the sheets when the workbook will be opened.

    Please Login or Register  to view this content.



  8. #8
    Registered User
    Join Date
    01-31-2008
    MS-Off Ver
    2010
    Posts
    38

    Re: Undo all changes since open or last save

    Quote Originally Posted by snb View Post
    Keep it simple: there's no need to hide sheets when closing if you hide the sheets when the workbook will be opened.
    The reason I like the idea of hidding the sheets on exit as well is because it turns them all off so if someone was to access the file and disable macros at startup then the all the sheets visible from the last time it was opened would still be there. I use a basic 'login screen' upon opening the spreadsheet and depending on who that is it displays/hides certain sheets. So if the manager was the last to save it and then a standard user opens it with macros disabled he'll see the additonal sheets he shouldn't because the login prompt wouldn't run. I know excel isn't a secure environment as such but I wanted to prevent the average guy from being able to circumvent the system and disabling macros is a very easy one for someone to do.

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Undo all changes since open or last save

    Your request is a little different. You are asking how to archive previous versions on save but don't have a specific rule. You might want to save but sometimes not. These save or not, without a set rule is tough to decide how to resolve the problem.

    After re-reading your question perhaps this will work. You can just pretend that the workbook has been saved with a command like:
    Please Login or Register  to view this content.
    It doesn't really save the workbook but when you do close it - it won't ask to be saved.

    Is this what you were looking for?

  10. #10
    Registered User
    Join Date
    01-31-2008
    MS-Off Ver
    2010
    Posts
    38

    Re: Undo all changes since open or last save

    Quote Originally Posted by MarvinP View Post
    Your request is a little different. You are asking how to archive previous versions on save but don't have a specific rule. You might want to save but sometimes not. These save or not, without a set rule is tough to decide how to resolve the problem.

    After re-reading your question perhaps this will work. You can just pretend that the workbook has been saved with a command like:
    Please Login or Register  to view this content.
    It doesn't really save the workbook but when you do close it - it won't ask to be saved.

    Is this what you were looking for?
    No, I'm not bothered about the archive thing, that was just an idea I had to perhaps get round my problem but creating many copies of the file isn't practical.

    This is my exit code:
    Please Login or Register  to view this content.
    It turns off all the sheets except 'Welcome' and does a force save (no prompt) then close ...exactly what I need to keep the sheets invisible even when the file is closed. However ....and this is the problem ...what's to stop a user opening the file making a complete hash of the numbers and then exiting out expecting to be able to NOT save changes and bam, my code automatically saves the changes. I need the option to be able to undo their work (if they want) and then do my force save ...but I must have my force save at the end.

    Making any more sense?

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Undo all changes since open or last save

    I don't have a good answer for you.

  12. #12
    Registered User
    Join Date
    08-18-2015
    Location
    Egypt
    MS-Off Ver
    2010
    Posts
    6

    Re: Undo all changes since open or last save

    I know it's an old post, but is there is any chance that someone has found a solution for this in the past 5 years ?
    I've exactly the same problem !!

  13. #13
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Undo all changes since open or last save

    i7ooo,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

  14. #14
    Registered User
    Join Date
    08-18-2015
    Location
    Egypt
    MS-Off Ver
    2010
    Posts
    6

    Re: Undo all changes since open or last save

    Sorry protonleah, I thought it's ok since it's still unsolved and I just want the answer of the original post not a new question. I'm still new here
    Thanks for the notice anyway.

+ 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