Con questa routine chiudo il programma Excel
Sub PROCESSIWINDOWSExcelElimina()
Dim MEssaggio As String
Dim objWMI As Object, objProcess As Object, objProcesses As Object
Set objWMI = GetObject("winmgmts://.")
Set objProcesses = objWMI.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'Excel.exe'")
For Each objProcess In objProcesses
Call objProcess.Terminate
Next
Set objProcesses = Nothing: Set objWMI = Nothing
End Sub
Funziona; ma se invece avessi diversi file Excel aperti e ne volessi chiudere uno solo?
Qualche suggerimento?