View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Keith Willshaw Keith Willshaw is offline
external usenet poster
 
Posts: 170
Default Running a batch file from VB


"Graham Carter" wrote in message
...
I noticed the posting from this mroning on printing PDF
files and managed to get the batch file to run using
ShellExecute. Now I just have to figure out how to change
the directory before runnign the batch file and how to
close the command prompt shell ...


Use the Shell function, the VBA help file
describes it

Shell(pathname[,windowstyle])

Pathname is the full pathname of the program

e.g.

' Specifying 1 as the second argument opens the application in
' normal size and gives it the focus.
Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator.
Keith