View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Michael Bednarek[_5_] Michael Bednarek[_5_] is offline
external usenet poster
 
Posts: 4
Default Batch file to start multiple excel files with auto_open() macro. Delay code needed

On 26 May 2005 12:11:13 -0700, wrote in
microsoft.public.excel.programming:

I'm under Win2k

And here's my VA code:

Sub auto_Open()
Application.OnTime Now + TimeValue("00:00:03"), "update"
End Sub

'This is a Datastream update
Sub update()
Sheets("REQUEST_TABLE").Select
Application.Run "autoopen.xls!StartProcessingRT"
Application.OnTime Now + TimeValue("00:00:05"), "Save_Exit"
End Sub

Sub Save_Exit()
ActiveWorkbook.Close True
End Sub


An analysis of that code tells me that Excel doesn't seem to exit after
opening autoopen.xls, and consequently the batch file should never get
to execute the second line (autoopen2.xls). To verify this, I created
two workbooks with these names, put your VBA code into those workbooks,
and created a batch file (test.cmd):
START "" /WAIT autoopen.xls
START "" /WAIT autoopen2.xls
Running that batch file produced exactly the expected results: the 1st
workbook opened, the VBA code executed, including closing the workbook,
and then Excel just sat there, and so did the batch file.

I had to close the first workbook manually to allow the batch file to
continue with the second workbook. In order to end the batch file, I had
to manually close the second workbook.

I think Datastream (AdvanceOffice.xla) has its own auto_open VBA module,
but I doubt that could be the cause of the behaviour you describe. I
might run a full test including Datastream updating over the weekend,
but I really doubt any benefit.

In the meantime, what happens if you run the following batch file:
START "" /WAIT CALC
START "" /WAIT NOTEPAD
Do the two applications execute strictly one-after-the-other or (almost)
simultaneously? They should do the latter and they do so here.

--
Michael Bednarek
http://mbednarek.com/ "POST NO BILLS"