Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Tuer un process Excel qui tourne en background

1 réponse
Avatar
valentin
Bonsoir,
Quelqu'un connait - il l'API à utiliser pour tuer un process
Excel qui tourne en tâche de fond ?
Il me faut absolument utiliser cette méthode ( sous XP , Excel 2003 ).
Merci par avance
Valentin

1 réponse

Avatar
LSteph
Bonsoir,

http://cjoint.com/?eswMz6eG0G

'1 Userform 1 combo 1 liste 1 CommandButton

'le code du userform:


''''''''''''''''''''''''''''''

Dim svc As Object
Dim myQuery As String
Dim myp

Private Sub CommandButton1_Click()
KillProcess ComboBox1
End Sub

Private Sub UserForm_Initialize()


On Error GoTo UIniError

Set svc = GetObject("winmgmts:rootcimv2")
myQuery = "select * from win32_process"
For Each myp In svc.execquery(myQuery)
ListBox1.AddItem myp.Name & " = " & myp.ExecutablePath
ComboBox1.AddItem myp.Name
Next
Set svc = Nothing
Exit Sub

UIniError:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")"
Err.Clear
End Sub

Public Function KillProcess(ByVal ProcessName As String) As Boolean

Set svc = GetObject("winmgmts:rootcimv2")
myQuery = "select * from win32_process where name='" & ProcessName
& "'"
For Each myp In svc.execquery(myQuery)
myp.Terminate
Next
Set svc = Nothing
End Function

''''''''''''''''''''''''''

'Cdlt

'lSteph


Bonsoir,
Quelqu'un connait - il l'API à utiliser pour tuer un process
Excel qui tourne en tâche de fond ?
Il me faut absolument utiliser cette méthode ( sous XP , Excel 2003 ).
Merci par avance
Valentin