+ Reply to Thread
Results 1 to 2 of 2

Save an open workbook, then open template workbook and close the saved workbook

Hybrid View

ondvirg Save an open workbook, then... 10-27-2009, 04:03 PM
shg Re: Save an open work, then... 10-27-2009, 10:20 PM
  1. #1
    Registered User
    Join Date
    10-27-2009
    Location
    Humboldt, TN
    MS-Off Ver
    Excel 2003
    Posts
    1

    Save an open workbook, then open template workbook and close the saved workbook

    I have a template Workbook named "LINE11.xls" when opened it creates a new Workbook named "LINE11 mm-dd-yyyy" the date being the day it was opened. What I could use help with is getting it to save and close at mid-night, and then open the template "LINE11.xls" to start a new Workbook for the next day. I am new to vba and this has been messing with me for quite sometime. Any help would be greatly apprieciated. It seems to be close, but I am sure there is a better way.

    (code is in ThisWorkbook)
    
    Private Sub Workbook_Open()
        
        Application.OnTime TimeValue("02:10:00"), "Save_Close_Active_File"
        
    End Sub
    
    
    
    (This code is in a module)
    
    Sub Save_Close_Active_File()
    
    Dim LastActiveWorkBook As String
    
        Application.OnTime TimeValue("02:10:00"), "Save_Close_Active_File"
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Name
        LastActiveWorkBook = ActiveWorkbook.Name
        Workbooks.Open Filename:="E:\LINE11.xls"
        Windows("LastActiveWorkBook").Activate
        ActiveWorkbook.Close
        Application.DisplayAlerts = True
    
    
        
    End Sub
    Last edited by ondvirg; 10-28-2009 at 03:42 PM. Reason: misspelling

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Save an open work, then open template workbook and close the saved workbook

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

+ 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