Try this:

 

Public Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long

 

Sub shellit()

Dim PID As Long, h As Long

PID = Shell(CurDir & "\batchfile.bat", vbNormalFocus) 

Wait 1 'wait for the window to arrive

h = GetForeGroundhWnd         'this is a BostonWorkStation function

Do

    Wait

Loop Until IsWindow(h) = 0      'loop until the window disappears

End Sub

 

Rich McNeil

Boston Software Systems

866 653 5105 x 813

www.bostonworkstation.com

 

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Davy Montgomery
Sent: Saturday, March 29, 2008 7:34 PM
To: [email protected]
Subject: RE: [Talk] Method to see if an application is running

 

I have a similar question.  It is my understanding that you can obtain the
Process ID of anything you shell out.  That is if I wanted to run a batch
file and obtain the process id I could do.

 

Dim PID as Double

PID = Shell("C:\Batchfile.bat")

 

My question is now that you know the process id can you then check to see if
it is still running.  I want to wait until the batch file finishes to move
on with my program.  So I need to be able to determine if that PID is still
active or not.

 

Thanks,
Davy

>>> "Scaccia, Kimberly" <[EMAIL PROTECTED]> 3/25/2008 12:56 PM
>>>

Only works when Excel is active. I activate excel a lot to use functions and
VB Code applied to my spreadsheets (ie put in formulas before Boston opens
in datastation) 

 

 

Kim Scaccia, System Admin

Recovery Reimbursement

Patient Business & Financial Services

Halifax Medical Center

386-226-4590 opt 1 ext 2018

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lawrence, Mitchell
Sent: Tuesday, March 25, 2008 12:43 PM
To: [EMAIL PROTECTED]
Subject: RE: [Talk] Method to see if an application is running

 

Does this work even when excel does not have an active window actually open
(IE when excel is being used by BWS)

 

 

Thank you,

Mitch Lawrence

Lead Applications Analyst

Technical Support - NPR/Automation

CHRISTUS Information Management

T:  <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]



Send a " <http://intranet.christushealth.org/spiritBuck/Default.asp> thank
you" to someone!

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Scaccia, Kimberly
Sent: Tuesday, March 25, 2008 11:29 AM
To: [email protected]
Subject: RE: [Talk] Method to see if an application is running

 

I have one that checks to see if Excel is running and if it is, close it:
Works beautifully: 

 

Sub WaitForExcelToShutDown()

Dim obj As Object

On Error GoTo trap

Do

    Set obj = GetObject(, "Excel.Application")   'this will fail if Excel
Isnt running

    obj.quit

    Set obj = Nothing

    Wait 2

Loop

 

Exit Sub

 

trap:

    'we're in the clear

    

End Sub

 

Kim Scaccia, System Admin

Recovery Reimbursement

Patient Business & Financial Services

Halifax Medical Center

386-226-4590 opt 1 ext 2018

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lawrence, Mitchell
Sent: Tuesday, March 25, 2008 11:27 AM
To: [email protected]
Subject: [Talk] Method to see if an application is running

 

Good morning all. Happy spring!

 

Does anyone have a method to check running processes to see if a particular
application is running?

 

I've got several scheduled scripts that utilize the same spreadsheet for
input data. I would like to, when the script starts, check to see if
excel.exe is already in the list of running processes and then take action
dependent upon the results of that query. Action 1 if excel is already
running, action 2 if it is not.

 

 

Thank you,

Mitch Lawrence

Lead Applications Analyst

Technical Support - NPR/Automation

CHRISTUS Information Management

T:  <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]



Send a " <http://intranet.christushealth.org/spiritBuck/Default.asp> thank
you" to someone!

 


CONFIDENTIALITY NOTICE: This email message, including attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the
intended recipient, please contact the sender by reply email and
destroy all copies of the original message.



<<image001.jpg>>

Reply via email to