calandrelli
Technical User
From Excel (VBA) I am opening a program without any VB objects (Document Direct) by executing a .bat file that contains a script. Document Dirtect downloads a report from a MVS system into a giant text file (40 - 50 Megs). Since I have no control of the Document Direct program, the only way that my code knwows that it is done is by looking at the file size of the document it is downloading every minute or two and compairing its file size to its previous size. Once the two match I know it is done and can allow the code to move on. The problem arrises when network traffic is heavy and the Document Direct stalls out for more than a minute and the code moves on prematurely. Is there a better way to control the external program? Can I detect when the program is open and closed through windows?
'***********************************************************
'*Open Document Direct script *
'***********************************************************
'
Shell PATHNAME:="\\addapdp1\pbo_db\Databases\LateJobs database\Bat Files\AMM31 SCRIPT MON.bat", _
WindowStyle:=vbNormalFocus
'Set a file system to examine files outside of Excel
Set fs = CreateObject("Scripting.FileSystemObject")
T = Time
Application.Wait (T + 0.0007)
Set f = fs.getfile("\\addapdp1\pbo_db\Databases\LateJobs database\Document Direct Reports\Latejobs_CURRENT.RPT")
Do
Test1 = f.Size
T = Time
Application.Wait (T + 0.0007) 'delay 60 seconds
Test2 = f.Size
Loop Until Test1 = Test2
'***********************************************************
'*Open Document Direct script *
'***********************************************************
'
Shell PATHNAME:="\\addapdp1\pbo_db\Databases\LateJobs database\Bat Files\AMM31 SCRIPT MON.bat", _
WindowStyle:=vbNormalFocus
'Set a file system to examine files outside of Excel
Set fs = CreateObject("Scripting.FileSystemObject")
T = Time
Application.Wait (T + 0.0007)
Set f = fs.getfile("\\addapdp1\pbo_db\Databases\LateJobs database\Document Direct Reports\Latejobs_CURRENT.RPT")
Do
Test1 = f.Size
T = Time
Application.Wait (T + 0.0007) 'delay 60 seconds
Test2 = f.Size
Loop Until Test1 = Test2