hi all - thanks for your help in anticipation. I work in IT but don't know VBA at all unfortunately. Wondered if you could help me amend the following code
-----------------------------------------
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Create_BackUp SourceWB:=Me, Path:="C:\Users\ian.woodland\Dropbox\irw\CMC\CMC Back Ups"
End Sub
Private Sub Create_BackUp(SourceWB As Workbook, Path As String)
Dim oWB As Workbook
On Error Resume Next
Set oWB = Workbooks("BackUp Of " & SourceWB.Name)
If Err = 0 And oWB.Path & _
Application.PathSeparator = Path Then
oWB.Close True
End If
Kill oWB.FullName
If Not SourceWB.Name Like "BackUp*" Then
SourceWB.SaveCopyAs Path & "BackUp " & SourceWB.Name
End If
End Sub
--------------------------------------------------------
This automatically puts a copy of my excel file in a different location when i close my file.
Wondered if someone could amend the code so that the file name includes the date and time as part of the file name. Preferably YYYY-MM-DD HH.MM.
Thanks again in anticipation!
Ian W - Sunny and cold England!
-----------------------------------------
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Create_BackUp SourceWB:=Me, Path:="C:\Users\ian.woodland\Dropbox\irw\CMC\CMC Back Ups"
End Sub
Private Sub Create_BackUp(SourceWB As Workbook, Path As String)
Dim oWB As Workbook
On Error Resume Next
Set oWB = Workbooks("BackUp Of " & SourceWB.Name)
If Err = 0 And oWB.Path & _
Application.PathSeparator = Path Then
oWB.Close True
End If
Kill oWB.FullName
If Not SourceWB.Name Like "BackUp*" Then
SourceWB.SaveCopyAs Path & "BackUp " & SourceWB.Name
End If
End Sub
--------------------------------------------------------
This automatically puts a copy of my excel file in a different location when i close my file.
Wondered if someone could amend the code so that the file name includes the date and time as part of the file name. Preferably YYYY-MM-DD HH.MM.
Thanks again in anticipation!
Ian W - Sunny and cold England!