Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1212to1216
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

VBA: Andere Anwendung

VBA: Andere Anwendung
Peter/Berlin
Hallo VBA-Fans,
die Anwendung xyz.exe wird manuell gestartet mit Doppelklick (nicht mit Shell aus VBA).
Wie kann ich mit VBA testen/feststellen,
ob die Anwendung xyz.exe z.Zt. gerade geöffnet ist?
Vielleicht mit
AppActivate pfad & "xyz.exe"
was eine Fehlermeldung verursacht, wenn das angegebene Anwendungsfenster nicht gefunden wird?
Über Hilfe von Euch würde ich mich sehr freuen!
Gruß Peter

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: VBA: Andere Anwendung
11.05.2011 16:59:33
Mäxl
Hi
Private Declare Sub CloseHandle Lib "Kernel32" ( _
ByVal hPass As Long)
Private Declare Function CreateToolhelpSnapshot Lib "Kernel32" _
Alias "CreateToolhelp32Snapshot" ( _
ByVal lFlgas As Long, _
ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "Kernel32" _
Alias "Process32First" ( _
ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "Kernel32" _
Alias "Process32Next" ( _
ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long
Private Const TH32CS_SNAPPROCESS As Long = 2&
Private Const MAX_PATH As Long = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwflags As Long
szexeFile As String * MAX_PATH
End Type
Private Function CheckEXE(ByVal sFilename As String) As Long
Dim lngSnapshot As Long
Dim uProcess As PROCESSENTRY32
Dim Checkproc As Long
lngSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
If lngSnapshot  0 Then
uProcess.dwSize = Len(uProcess)
Checkproc = ProcessFirst(lngSnapshot, uProcess)
Do Until Checkproc = 0
If InStr(LCase$(uProcess.szexeFile), LCase$(sFilename)) > 0 Then
CheckEXE = True
Exit Do
End If
Checkproc = ProcessNext(lngSnapshot, uProcess)
Loop
CloseHandle lngSnapshot
End If
End Function
Sub exe()
If CheckEXE("xyz.exe") Then
MsgBox "die EXE ist gestartet", vbInformation
End If
End Sub vgl.
http://www.vbarchiv.net/tipps/details.php?id=572
Anzeige
VBA: Andere Anwendung
11.05.2011 19:07:44
Anton
Hallo Peter ,
oder so:
Code:

Sub b()
  strProgramm = "'xyz.exe'"
  Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")  
  Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " & strProgramm)  
  If colProcessList.Count > 0 Then MsgBox strProgramm & " geöffnet"  
End Sub  


mfg Anton
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige