Creating a read only backup??

S

Simon Lloyd

Hi all,

I have this code in the this workbook module which works fine but
would like to make one tweak to it.....i would like the back up copy t
be read only, can anyone help with the line i should insert to do this?

Simon

Here's the code!....

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim lDat_Today As Date
Dim lDat_Tomorrow As Date
Dim lStr_TargetFile As String

lDat_Today = Date
If "Fri" = Format(Date, "ddd") Then
lDat_Tomorrow = Date + 3
Else
lDat_Tomorrow = Date + 1
End If

With ThisWorkbook
If Month(lDat_Today) = Month(lDat_Tomorrow) Then
Else
.SaveCopyAs ThisWorkbook.Path & "\" & _
Left(ThisWorkbook.Name, InStr(1, LCase(ThisWorkbook.Name),
".xls") - 1) & _
" - " & Format(Now, "yyyymmdd") & ".xls"
End If

.Save

End With
End Su
 
T

Tom Ogilvy

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim lDat_Today As Date
Dim lDat_Tomorrow As Date
Dim lStr_TargetFile As String
Dim sStr as String

lDat_Today = Date
If "Fri" = Format(Date, "ddd") Then
lDat_Tomorrow = Date + 3
Else
lDat_Tomorrow = Date + 1
End If

With ThisWorkbook
If Month(lDat_Today) = Month(lDat_Tomorrow) Then
Else
sStr = ThisWorkbook.Path & "\" & _
Left(ThisWorkbook.Name, InStr(1, _
LCase(ThisWorkbook.Name), _
".xls") - 1) & _
" - " & Format(Now, "yyyymmdd") & ".xls"
End If

.SaveCopyAs sName
setattr sName, vbReadOnly
.Save

End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top