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
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
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks