Hi all
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:
echo off
:: set drive=M:\mybackup
SET dateNtime="%date:~0,2%-%date:~3,2%-%date:~6,6%_%time:~0,2%-%time:~3,2%"
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)?
Bookmarks