I am trying to set up a macro to save a file in a specific location 2x a day with a new filename. It works when I manually run the macro, however, this is a shared file and I need it to save automatically without someone initiating it.
This is the code I have in place... What am I doing wrong?
Sub AMBackUp()
Dim MyFilePath As String
Dim MyFileDate As String
Dim MyFileName As String
MyFilePath = "C:\"
MyFileDate = Format(Date, "mm-dd-yyyy")
MyFileName = "Workbook_" & MyFileDate & "_AM"
ActiveWorkbook.SaveCopyAs Filename:=MyFilePath & MyFileName & ".xlsx"
End Sub
Sub PMBackUp()
Dim MyFilePath As String
Dim MyFileDate As String
Dim MyFileName As String
MyFilePath = "C:\"
MyFileDate = Format(Date, "mm-dd-yyyy")
MyFileName = "Workbook_" & MyFileDate & "_PM"
ActiveWorkbook.SaveCopyAs Filename:=MyFilePath & MyFileName & ".xlsx"
End Sub
Private Sub Workbook_Open()
Application.OnTime TimeValue("08:00:00"), Procedure:="AMBackUp"
Application.OnTime TimeValue("17:00:00"), Procedure:="PMBackUp"
End Sub
This is the code I have in place... What am I doing wrong?
Sub AMBackUp()
Dim MyFilePath As String
Dim MyFileDate As String
Dim MyFileName As String
MyFilePath = "C:\"
MyFileDate = Format(Date, "mm-dd-yyyy")
MyFileName = "Workbook_" & MyFileDate & "_AM"
ActiveWorkbook.SaveCopyAs Filename:=MyFilePath & MyFileName & ".xlsx"
End Sub
Sub PMBackUp()
Dim MyFilePath As String
Dim MyFileDate As String
Dim MyFileName As String
MyFilePath = "C:\"
MyFileDate = Format(Date, "mm-dd-yyyy")
MyFileName = "Workbook_" & MyFileDate & "_PM"
ActiveWorkbook.SaveCopyAs Filename:=MyFilePath & MyFileName & ".xlsx"
End Sub
Private Sub Workbook_Open()
Application.OnTime TimeValue("08:00:00"), Procedure:="AMBackUp"
Application.OnTime TimeValue("17:00:00"), Procedure:="PMBackUp"
End Sub