Sub Close_it()
Dim StrPath As String
StrPath = "\\PublicI\\3.QGIS\MAPA.qgs"
Call Close_Notepad_ByName(StrPath)
End Sub
Public Sub Close_Notepad_ByName(NtpPath As String)
Dim oServ As Object
Dim cProc As Object
Dim oProc As Object
StrProcessName = "MAPA.exe" '<<<<<<<<< form Task manger get the correct type of program Like: Word= WINWORD.EXE, text= Notepad.exeexcel= EXCEL.EXE,
Set oServ = GetObject("winmgmts:")
Set cProc = oServ.ExecQuery("select * from win32_process")
For Each oProc In cProc
If InStr(1, oProc.Name, StrProcessName, vbTextCompare) <> 0 Then
If InStr(1, oProc.CommandLine, NtpPath, vbTextCompare) <> 0 Then
oProc.Terminate
End If
End If
Next
Set oServ = Nothing
Set cProc = Nothing
End Sub