PC Review


Reply
Thread Tools Rate Thread

Application.Wait

 
 
UB
Guest
Posts: n/a
 
      30th Jan 2012
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.

 
Reply With Quote
 
 
 
 
John Coleman
Guest
Posts: n/a
 
      30th Jan 2012
On Jan 30, 4:41*am, UB <benakal....@gmail.com> wrote:
> 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.


 
Reply With Quote
 
GS
Guest
Posts: n/a
 
      30th Jan 2012
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

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:15 PM.