Application.Wait

U

UB

I need this help in VBA coding.

I'm currently using Application.wait Now + TimeValue("00:00:10") for
the period during which the code is read into another software and
'processed'. Most instances - this would be too short a period. The
time requried to process in the otehr sopftware would be entirely
dependent on the data size.

Can you help me with certain code, which will keep the other software
open till the processing is complete and then quits automatically -
without hard coded TimeValue.
 
J

John Coleman

I need this help in VBA coding.

I'm currently using Application.wait Now + TimeValue("00:00:10")  for
the period during which the code is read into another software and
'processed'. Most instances - this would be too short a period. The
time requried to process in the otehr sopftware would be entirely
dependent on the data size.

Can you help me with certain code, which will keep the other software
open till the processing is complete and then quits automatically -
without hard coded TimeValue.

One possibility is to try to use VBScript's Run command (which can
call external programs synchronously). In your VBA project insert a
reference (via Tools/References) to the Windows Script Host Object
Model. Then something along the following might work:

Sub test()
Dim WShell As New WshShell
WShell.Run "Calc", WaitOnReturn:=True
MsgBox ("Done!")
End Sub

'************************************************
Note that when you run the above that the message box doesn't appear
until *after* you close calc.

Hope that helps.
 
G

GS

UB was thinking very hard :
I need this help in VBA coding.

I'm currently using Application.wait Now + TimeValue("00:00:10") for
the period during which the code is read into another software and
'processed'. Most instances - this would be too short a period. The
time requried to process in the otehr sopftware would be entirely
dependent on the data size.

Can you help me with certain code, which will keep the other software
open till the processing is complete and then quits automatically -
without hard coded TimeValue.

To add to John's excellent example, you can also use VB's 'Shell()'
feature with no external dependancy. (Some corporate network
ActiveDirectory GroupPolicies disable scripting libraries on local
workstations, and so John's suggestion will not work!) The Shell()
function can be used along with Windows APIs as in this example...

http://www.appspro.com/Downloads/ShellAndWait.zip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top