LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Running Batch File from within Excel


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
batch file to ftp code not running - please help! WhytheQ Excel Programming 0 February 10th 10 05:55 PM
Running a Batch file from VBA D.riggins Excel Programming 6 September 1st 09 08:54 PM
running a batch file Mohan[_2_] Excel Programming 3 April 10th 04 10:48 PM
Running a batch file from VB Graham Carter Excel Programming 3 August 29th 03 04:18 PM
Running a batch file from Excel VBA verizon Excel Programming 1 July 20th 03 09:27 AM


All times are GMT +1. The time now is 08:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"