I want to have a batch file that runs automatically whenever a particular workbook is opened. So I need help working out what VBA command to use (the Shell command?), and where to put it in Excel.
I could also do with help getting the batch file code working if anyone here knows about that stuff:
:: set drive=M:\mybackup
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y
%backupcmd% "*.xls" "\Backups\*%dateNtime.xls"
What I want this batch file to do is copy all "xls" files from the current directory to a subdirectory, with the date and time appended on the end, and put them in a "Backups" subdirectory. Then I can copy the batch file to all of the other directories without having to change filenames. Also there is one directory which has five to backup rather than one. Does anyone know how I can get this batch file work?
And does anyone know where I can put the Shell command in Excel to run the batch file when the workbook is opened (and possibly when certain VBA subroutines are ran)?