Hi ,
I am using this code to make an automatic copy of work book in other destinations.
I am learning on how to write the code.
My file name is ABCDE and it is at C:/TP/NN ( NN is the folder)
Path where back up copy is to be saved is C:/TP/BK( BK is the name of the folder)
I want the data on back copy saved every time the main copy is modified, however if some one tries to delete any information, then the back up copy remains as it is.
How it can be possible???
I have a general code, but dont know how to rewrite it.
Please help...
Sub MyBackup()
' Saves a renamed copy of this workbook in the nominated folder as a backup.
' Pre-requisite: PathExists Function (see below)
Dim fname As String
Dim Path As String
Dim PathnName As String
Dim Mydate as String
On Error Resume Next
MyDate = Format(Date, "yymmdd") & " "
Path = "[Specify path for backup here, including final \]"
fname = MyDate & ThisWorkbook.Name
PathnName = Path & fname
If PathExists(Path) Then
ThisWorkbook.SaveCopyAs PathnName
Else
Exit sub
End If
End Sub
Public Function PathExists(pname) As Boolean
' Returns TRUE if the path exists
' Code source: http://www.j-walk.com/ss/excel/tips/tip54.htm
Dim x As String
On Error Resume Next
x = GetAttr(pname) And 0
If Err = 0 Then PathExists = True Else PathExists = False
End Function
Bookmarks