I am using the following code to save back up files:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Saves the current file to a backup folder and the default folder
'Note that any backup is overwritten
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs ("C:\Users\User\Dropbox\Documents\Files and Rentals " & Format(Now(), "DD MMM YYYY hhmmss") & ".xlsm")
ActiveWorkbook.SaveCopyAs ("C:\Users\User\OneDrive\Rental Stuff\Files and Rentals " & Format(Now(), "DD MMM YYYY hhmmss") & ".xlsm")
ActiveWorkbook.SaveCopyAs ("Y:\Excel BackUp Docs\Files and Rentals " & Format(Now(), "DD MMM YYYY hhmmss") & ".xlsm")
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub
My question comes in my third ActiveWorkBook.SaveCopyAs statement. I use this workbook from two different locations. At home, I have the "Y:\" directory. At my work location, that directory doesnt exist. So what I am trying to do is code it that if the directory exists (I am at home), it will save a copy there, and if the directory doesnt exist (I am at work), it will just pass over it and go to the next line of ActiveWorkBook.Save.
Any help on coding this would be appreciated.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Saves the current file to a backup folder and the default folder
'Note that any backup is overwritten
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs ("C:\Users\User\Dropbox\Documents\Files and Rentals " & Format(Now(), "DD MMM YYYY hhmmss") & ".xlsm")
ActiveWorkbook.SaveCopyAs ("C:\Users\User\OneDrive\Rental Stuff\Files and Rentals " & Format(Now(), "DD MMM YYYY hhmmss") & ".xlsm")
ActiveWorkbook.SaveCopyAs ("Y:\Excel BackUp Docs\Files and Rentals " & Format(Now(), "DD MMM YYYY hhmmss") & ".xlsm")
ActiveWorkbook.Save
Application.DisplayAlerts = True
End Sub
My question comes in my third ActiveWorkBook.SaveCopyAs statement. I use this workbook from two different locations. At home, I have the "Y:\" directory. At my work location, that directory doesnt exist. So what I am trying to do is code it that if the directory exists (I am at home), it will save a copy there, and if the directory doesnt exist (I am at work), it will just pass over it and go to the next line of ActiveWorkBook.Save.
Any help on coding this would be appreciated.