+ Reply to Thread
Results 1 to 3 of 3

Auto close, save to new file without prompt

Hybrid View

  1. #1
    Registered User
    Join Date
    08-18-2006
    Posts
    43

    Auto close, save to new file without prompt

    I posted this question and got the answer to it. Thanks everyone who replies. I have to modify this though and I am not sure if it is possible to do so. The following is what i asked and what was answerd. My question will follow.

    Quote Originally Posted by Bafa
    Hello. I am trying to find the code that will allow me to close and exit the file I am working in and the Excel program without asking if I want to save. I just need an easy click and quit command button. Thanks for any help!

    Quote Originally Posted by mudraker
    You have a several ways to do it


    Application.DisplayAlerts = False
    ActiveWorkbook.Close
    Application.DisplayAlerts = True
    
    or
    
    ActiveWorkbook.Close SaveChanges:=False
    
    or
    
    ActiveWorkbook.Saved = True
    I have decided that it would be good to save a record on the PC of what was done as well as the hard copy I am required to keep. So what I need is for the master file I am working on to close without promting me to save it, but I do want it to save the info entered as a seperate file, preferably with the file name of the current date YY-MM-DD format. The reason is when the master file is open I want it to be void of all values, so when it closes I don't want the info that was entered to be saved there, but instead to have it automaticly create and name a new file and save all the info there upon closing the master file. So in my directory you would see a list like this:

    master.xls <- Never saves it self
    070522.xls \
    070615.xls - > These three were created by the master file closing
    070728.xls /

    I hope I haven't made this sound more complicated than it is. If anyone needs clairification of what I am doin please ask. Thanks everyone for all the help so far on this file I made almost a year ago and have been tweaking since. It got me the promotion at work that I wanted and reduced a 3 and a half hour difficult process down to flat 30 minute cake walk.

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Including this code in the Worbook_BeforeClose event procedure will save it as the current date:
        ThisWorkbook.SaveAs Format(Date, "yy-mm-dd")
    If you want to override the file (if you close the workbook more than once on the same date), then you can use:
        Application.DisplayAlerts = False
        ThisWorkbook.SaveAs Format(Date, "yy-mm-dd")
        Application.DisplayAlerts = True
    HTH

    Jason

  3. #3
    Registered User
    Join Date
    08-18-2006
    Posts
    43
    Application.DisplayAlerts = False
    ThisWorkbook.SaveAs Format(Date, "yy-mm-dd") <--This line is giving me a debug error
    Application.DisplayAlerts = True

    If you would like to see the code i have atm you can see my file here.
    Thank you.

+ 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