Auto save at specific times with changing saveas name
hello,
Type this in a notepad, edit the path for the .xls document in the
code and save it as a .VBS file. Setup Windows scheduler to run
this .VBS file at 12pm, 5pm, and 11:59pm and it'll do what your
looking for.
Dim xlApp
set xlApp = CreateObject("Excel.Application")
xlapp.workbooks.open "C:\Documents and Settings\G\Desktop\Z\test.xls"
xlApp.Visible = True
set xlwb = xlapp.activeworkbook
Dim idate
Dim itime
idate = Month(Now) & Day(Now) & Year(Now) 'Format(Date, "mmddyy")
itime = FormatDateTime(Round(Time * 24, 0.1) / 24,vbshorttime)
'Round(Time * 24, 0.1) / 24, "hmm")
Select Case itime
Case "12:00","13:00"
itime = 1200
Case "17:00","18:00"
itime = 1700
Case "22:00","23:00","24:00"
itime = 2359
End Select
xlWB.saveas "C:\Documents and Settings\G\Desktop\Z\" & "MyFile_" &
idate & "_" & itime & ".xls"
xlWB.close
xlapp.quit
set xlwb = nothing
set xlapp = nothing
|