Along the same lines, if you're looking to shell to a program and wait for the shelled program to finish before returning to VB, here's a class that will do that for you.<br>
<br>
Option Explicit<br>
<br>
Private Type STARTUPINFO<br>
cb As Long<br>
lpReserved As String<br>
lpDesktop As String<br>
lpTitle As String<br>
dwX As Long<br>
dwY As Long<br>
dwXSize As Long<br>
dwYSize As Long<br>
dwXCountChars As Long<br>
dwYCountChars As Long<br>
dwFillAttribute As Long<br>
dwFlags As Long<br>
wShowWindow As Integer<br>
cbReserved2 As Integer<br>
lpReserved2 As Long<br>
hStdInput As Long<br>
hStdOutput As Long<br>
hStdError As Long<br>
End Type<br>
<br>
Private Type PROCESS_INFORMATION<br>
hProcess As Long<br>
hThread As Long<br>
dwProcessID As Long<br>
dwThreadID As Long<br>
End Type<br>
<br>
Private Declare Function WaitForSingleObject Lib _<br>
"kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds _<br>
As Long) As Long<br>
<br>
Private Declare Function CreateProcessA Lib "kernel32" _<br>
(ByVal lpApplicationName As Long, ByVal lpCommandLine As _<br>
String, ByVal lpProcessAttributes As Long, ByVal _<br>
lpThreadAttributes As Long, ByVal bInheritHandles As Long, _<br>
ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, _<br>
ByVal lpCurrentDirectory As Long, lpStartupInfo As _<br>
STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) _<br>
As Long<br>
<br>
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject _<br>
As Long) As Long<br>
<br>
Private Const NORMAL_PRIORITY_CLASS = &H20&<br>
Private Const INFINITE = -1&<br>
<br>
Public Function ExecCmd(strCommandLine) As Long<br>
<br>
'Returns: Nonzero on success, zero on failure.<br>
<br>
Dim tProcess As PROCESS_INFORMATION<br>
Dim tStartup As STARTUPINFO<br>
Dim lReturn As Long<br>
<br>
On Error GoTo ExecCmdErr<br>
<br>
' Initialize the STARTUPINFO structure:<br>
tStartup.cb = Len(tStartup)<br>
<br>
' Start the shelled application:<br>
lReturn = CreateProcessA(0&, strCommandLine, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, tStartup, tProcess)<br>
<br>
' Wait for the shelled application to finish:<br>
lReturn = WaitForSingleObject(tProcess.hProcess, INFINITE)<br>
lReturn = CloseHandle(tProcess.hProcess)<br>
<br>
ExecCmd = lReturn<br>
<br>
Exit Function<br>
<br>
ExecCmdErr:<br>
'Return an error.<br>
ExecCmd = 0<br>
End Function<br>
<p>Steve Meier<br><a href=mailto:sdmeier@jcn1.com>sdmeier@jcn1.com</a><br><a href= > </a><br>