ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If Process Exists then (https://www.excelbanter.com/excel-programming/418469-if-process-exists-then.html)

Thomas

If Process Exists then
 
I need the Excel VBA equivalent code for "If Process exists then....endif".


Thank you.

Peter T

If Process Exists then
 
What do you mean by "Process"

Regards,
Peter T

"thomas" wrote in message
...
I need the Excel VBA equivalent code for "If Process exists then....endif".


Thank you.




Luke Alcatel

If Process Exists then
 
You'll need to work through additional details but I would start by making
psapi.dll function EnumProcesses available by using a Declare statement.
The remaining steps depend on exactly what you are looking for,

"thomas" wrote in message
...
I need the Excel VBA equivalent code for "If Process exists then....endif".


Thank you.




Chip Pearson

If Process Exists then
 

I need the Excel VBA equivalent code for "If Process exists then....endif".



By "process" do you mean a Windows process? Or something else? I
think you
need to clarify exactly what you want to test for.
For a Windows process whose Process ID is known, use code similar to
the
following:

''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function GetProcessVersion Lib "kernel32" ( _
ByVal ProcessID As Long) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long

Sub AAA()
Dim ProcID As Long
Dim Version As Long
Dim LastErr As Long
Dim ThisProcID As Long
ThisProcID = GetCurrentProcessId()
ProcID = 1234& ' specify process ID
' OR
ProcID = ThisProcID ' this process ID
Version = GetProcessVersion(ProcID)
LastErr = Err.LastDllError
If Version = 0 Then
If LastErr = &H57 Then
' processs does not exist
Debug.Print "Process does not exist"
Else
' process exists but access is denied
Debug.Print "Err: " & CStr(LastErr), _
GetSystemErrorMessageText(LastErr)
End If
Else
' process exists and is accessible:
Debug.Print "Process Exists. Version: " & Hex(Version)
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Mon, 13 Oct 2008 23:04:01 -0700, thomas
wrote:

I need the Excel VBA equivalent code for "If Process exists then....endif".


Thank you.


Thomas

If Process Exists then
 
Windows process is what I mean and Chip, your code saves the day for me.

Thank you all, gentlemen.


All times are GMT +1. The time now is 02:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com