PDA

View Full Version : [SOLVED] Can VBA codes call a bat file?



snoopies
07-15-2005, 01:33 AM
Hi all,

I may want to know if it is possible/ how to use VBA codes to call a BAT. file...

Thanks in advance.

Regards,

Bob Phillips
07-15-2005, 02:02 AM
I may want to know if it is possible/ how to use VBA codes to call a BAT. file...

You could Shell it



Sub TestShell_()
ChDrive "C"
ChDir "C:\"
Shell ("notepad.exe test02.txt")
Shell ("command.com x.bat")
End Sub

sheeeng
07-15-2005, 08:09 AM
.script12hide { display: none; }


You could Shell it



Sub TestShell_()
ChDrive "C"
ChDir "C:\"
Shell ("notepad.exe test02.txt")
Shell ("command.com x.bat")
End Sub


Great!
Simple yet sufficient.

snoopies
07-17-2005, 08:48 PM
I have a problem here..
if there the bat file is in c:\abc\XXX.bat

I change the codes to..


Sub TestShell_()
ChDrive "C"
ChDir "C:\abc\"
Shell ("command.com XXX.bat")
End Sub

It doesn't work.... what's wrong...??:(

Bob Phillips
07-18-2005, 02:13 AM
I have a problem here..
if there the bat file is in c:\abc\XXX.bat

I change the codes to..


Sub TestShell_()
ChDrive "C"
ChDir "C:\abc\"
Shell ("command.com XXX.bat")
End Sub

It doesn't work.... what's wrong...??:(

Trying shelling the file

Shell XXX.bat"