You can use the workbook open event to run something whenever the workbook is opened. In the ThisWorkbook object (in microsoft excel objects in the solution explorer for your vba project) put something like:
Private Sub Workbook_Open()
'do this code
End Sub
I'm not good with batch file code but you might be able to use something like this to just do it from vba:
Private sub workbooks_open()
Dim fs, fol, fil
Set fs = CreateObject("Scripting.filesystemobject")
Set fol = fs.getfolder("M:\mybackup")
For Each fil In fol.Files
If Strings.Right(fil, 4) = ".xls" Then
fil.Copy fil.ParentFolder & "\Backups\" & Replace(fil.name, ".xls", "") & replace(replace(Now(),"/",""),":","") & ".xls"
End If
Next
End Sub
Bookmarks