jansjane
Member
Code:
Option Explicit
Private Sub Workbook_Open()
UserForm1.Show
Application.Caption = "Microsoft Excel AutoBackup"
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim MyFilePath$, Extension$
MyFilePath = MyPCpath("MyDocuments")
Extension = Left(ThisWorkbook.Name, Len _
(ThisWorkbook.Name) - 4) & " Backup"
On Error Resume Next '<< folder exists
MkDir MyFilePath & Extension '<< create folder
'save current version of this book in the folder
ActiveWorkbook.SaveCopyAs Filename:=MyFilePath & _
Extension & "\" & Extension & _
(Format(Now, " mmm d yyyy, hh.mm.ss AMPM")) & ".xls"
End Sub
Public Function MyPCpath$(Folder)
MyPCpath = CreateObject("WScript.Shell").SpecialFolders _
(Folder) & Application.PathSeparator
End Function
I don't know whole a lot about VBA, I will greatly appreciate your help.
the network drive is T:/AB or \\new.ca\AB
__________________________________________________________________
Mod edit : thread moved to appropriate forum !
Last edited: