Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I'm trying to run a batch file from within Excel. The batch file zips up two files and renames the zip file with the date and time. It works fine when run in a DOS box, but when run from Excel, all I get is a DOS box flashing up *very* briefly, and that's it: the zip file isn't created. I'm very much a novice when it comes to VBA. I've tried various bits of code that I've found, but mostly they are smilar to this: Sub RunBatchFile() Dim RetVal RetVal = Shell("G:\From G Data\Data Files & Test Programs\Work Data\zipbatch.bat", 1) End Sub I've also tried some 'Shell and Wait' code which I have to admit were a bit over my head. However, one of them ran the Windows Calculator, and didn't complete until you'd closed Calculator. That worked perfectly, but when I substituted the name of my batch file (together with its full path) for "calc.exe", again, all I got was a very brief DOS Box, and no output zip file. If it's any help, my batch file looks like this: "C:\Program Files\System Utilities\WinZip\wzzip" "g:\From G Data\Data Files & Test Programs\Work Data\temp.zip" files "g:\From G Data\Data Files & Test Programs\Work Data\London 9100 Revisions.xls" "g:\From G Data\Data Files & Test Programs\Work Data\test auto.xls" set d=%date:~-4,4%%date:~-7,2%%date:~0,2% set d=%d: =_% set t=%time:~0,2%%time:~3,2% set t=%t: =0% RENAME "g:\From G Data\Data Files & Test Programs\Work Data\temp.zip" "IF098_132%d%%t%.zip" pause Any ideas where I might be going wrong? Many thanks in advance for any help, Chris. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
batch file to ftp code not running - please help! | Excel Programming | |||
Running a Batch file from VBA | Excel Programming | |||
running a batch file | Excel Programming | |||
Running a batch file from VB | Excel Programming | |||
Running a batch file from Excel VBA | Excel Programming |