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
Bookmarks