close another application vba

Ramses28

New Member
Joined
May 18, 2018
Messages
10
I have the following code to open an external app:

ActiveWorkbook.FollowHyperlink Address:=("\\PublicI\\3.QGIS\MAPA.qgs"), NewWindow:=True

What code can i use to close it?

Thanks
 
Found the solution.
It is just simple as:

AppActivate "QGIS 2.18.18 - MAPA"
SendKeys "%{F4}", True


thanks
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
VBA Code:
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
Task Manager.gif
 

Attachments

  • Picture1.gif
    Picture1.gif
    27.4 KB · Views: 10
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top