Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default If Process Exists then

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


Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default If Process Exists then

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

Thank you all, gentlemen.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to process first row. Greg Maxey[_3_] Excel Programming 1 March 26th 07 08:02 PM
If/then Process? Zane B Stein Excel Discussion (Misc queries) 1 December 20th 05 03:27 PM
How to count process running time ( process not finished) miao jie Excel Programming 0 January 13th 05 09:23 AM
How to count process running time ( process not finished) miao jie Excel Programming 2 January 12th 05 06:01 AM
step into process Tom Ogilvy Excel Programming 0 August 16th 03 12:46 PM


All times are GMT +1. The time now is 09:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"