ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autosave (https://www.excelbanter.com/excel-programming/418363-autosave.html)

Brad

Autosave
 
I'm trying to write a macro that when a master file is saved, it will
automatically save a read only copy in another folder, any suggestions?


Dave Peterson

Autosave
 
You could use a macro that saves a copy in your favorite backup folder and then
marks the file readonly (the windows attribute).

Option Explicit
Sub testme01()
Dim myPath As String
Dim myFileName As String

myPath = "C:\backups"
If Right(myPath, 1) < "\" Then
myPath = myPath & "\"
End If

With ThisWorkbook
'save the workbook
.Save

myFileName = myPath & .Name

On Error Resume Next 'in case it's not there
'vbNormal will allow the code to overwrite the file
SetAttr pathname:=myFileName, attributes:=vbNormal
On Error GoTo 0

.SaveCopyAs Filename:=myFileName
SetAttr pathname:=myFileName, attributes:=vbReadOnly

End With

End Sub

Brad wrote:

I'm trying to write a macro that when a master file is saved, it will
automatically save a read only copy in another folder, any suggestions?


--

Dave Peterson


All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com