How to close Access aplication if is opened?
Printable View
How to close Access aplication if is opened?
The first thing that I would try is clicking in the X in the right top of the window.
If that doesn't work, right-click your taskbar, select task manager, select Access, right-click it, and say 'End Task'.
Now, if you want to do it from VB6, there are several posts that have discussed how to kill a task, some that I have posted. But I'll let you search for those. Do you need instructions on how to search?
Solution 1 shows how to close the application:
To terminate the processus;Code:Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As Long) As Long
Declare Function PostMessageA Lib "user32" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Sub CloseAccess()
Const WM_CLOSE = 16
Dim hWnd As Long
hWnd = FindWindowA("OMAIN", 0)
If hWnd <> 0 Then
PostMessageA hWnd, WM_CLOSE, 0, 0
End If
End Sub
Code:strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Process")
For Each objItem In colItems
If StrComp(objItem.Name, "MsAccess.exe", vbTextCompare) = 0 Then
objItem.Terminate
End If
Next