Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launch batch File with argumnets from VB

Status
Not open for further replies.

Befuddled

Aerospace
Joined
Jan 9, 2008
Messages
78
Location
GB
Strictly speaking i am using the VBA inside of excel (don't have full VB at work)

I am using it to A create user friendly front end to launch a batch file, which holds passwords etc.

My brain has gone completly blank on how to launch a batch file & pass it some variables from the VBA in excel.

my test batch file is:-
@echo off
echo hello world
echo %1
pause

I am trying to use the shell command in vba, but have got the syntax wrong somehwere:-
RetVal = shell("c:\Documents and Settings\abc\Desktop\test1.bat " & hello, vbNormalFocus)

i am expecting to see a command window, which echos 'hello world & hello' then press any key blah blah!!!

any ideas, is it possible?

Cheers in advance,

B
 
Add quotes around the text string that you want to pass to the .bat file.

Change
Code:
RetVal = shell("c:\Documents and Settings\abc\Desktop\test1.bat " & hello, vbNormalFocus)
to
Code:
RetVal = shell("c:\Documents and Settings\abc\Desktop\test1.bat " & "hello", vbNormalFocus)

ie change hello to "hello".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top