De: Peter Beach Objet: Re: Alternatives to Shell command?? Date : jeudi 28 octobre 1999 07:47 Paul, I suspect that Jake's suggestions of using a control is probably the route down which you ought to go. if you want to wait for Shell to complete try the following: declare function OpenProcess Lib "kernel32" _ (ByVal dwDesiredAccess As long, _ ByVal bInheritHandle As long, _ ByVal dwProcessId As long) As long declare function GetExitCodeProcess Lib "kernel32" _ (ByVal hProcess As long, _ lpExitCode As long) As long Public Const PROCESS_QUERY_INFORMATION = &H400 Public Const STILL_ACTIVE = &H103 Sub ShellAndWait(ByVal Pathname As String, Optional windowstate) dim hProg As long dim hProcess As long, ExitCode As long 'fill in the missing parameter and execute the program if IsMissing(windowstate) then windowstate = 1 hProg = Shell(Pathname, windowstate) 'hProg is a "process ID under Win32. to get the process handle: hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, false, hProg) do 'populate Exitcode variable GetExitCodeProcess hProcess, ExitCode doEvents loop While ExitCode = STILL_ACTIVE end Sub HTH Peter Beach Excel MVP Paul Helgesen wrote in message news:kmIR3.13687$7G2.83809@news1.online.no... > Hi! > > I have a VBA program like this : > > Shell ("C:\ftpstart.bat") 'Start an ftp session and get a file on a remote > server > ... > import that file in an excel Worksheet > > The problem is that shell runs asyncynchronously....that is: The program > tries to open the file before the shell command is finished.. > > So is there an alternative way to start an ftp-session an get a file?? > > -Paul- > > >