Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro for saving file on Auto Date
I want to know while writing a Macro how to automatically save a file which
is open on current date. Say File xxx.xls as xxx_date.xls. This has to be done automatically. Help me in solving this. Thanks, -- Prakash |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro for saving file on Auto Date
This makes a dated back up read only copy of a file at the end of each month if it is opened at the end of the month taking in to account not being used at weekends please feel free to modify this code to suit your needs. Simon Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim lDat_Today As Date Dim lDat_Tomorrow As Date Dim sStr As String Dim myattr With ThisWorkbook If ActiveWorkbook.ReadOnly Then Exit Sub lDat_Today = Date If Format(Date, "ddd") = "Fri" Then lDat_Tomorrow = Date + 3 Else lDat_Tomorrow = Date + 1 End If If Not Month(lDat_Today) = Month(lDat_Tomorrow) Then sStr = .Path & "\" & _ Left(.Name, InStr(1, _ LCase(.Name), _ ".xls") - 1) & _ " - " & Format(Now, "yyyymmdd") & ".xls" On Error Resume Next SaveCopyAs sStr On Error GoTo 0 SetAttr sStr, vbReadOnly End If End With End Sub -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=387166 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excels auto recovery file is saving as a backup, how do i stop tha | Setting up and Configuration of Excel | |||
auto saving & closing file | Excel Worksheet Functions | |||
Saving a copy of excel file in macro but have it auto write | Excel Worksheet Functions | |||
Saving worksheet in new file with date AND cell value as file name | Excel Discussion (Misc queries) | |||
Saving file as a date | Excel Programming |