0

I found a code which would help one of my projects. However I can't use it in my 64bit MS Access.

This was the original post How to get Application name from process name?

Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As Int32, ByRef lpdwProcessId 
As Int32) As Int32
Private Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As IntPtr
'Private Declare Auto Function GetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal 
lpString As System.Text.StringBuilder, ByVal cch As Integer) As Integer
Private makel As String

Private Function GetActiveAppProcess() As Process
Dim activeProcessID As IntPtr
GetWindowThreadProcessId(GetForegroundWindow(), activeProcessID)
Return Process.GetProcessById(activeProcessID)
End Function

Sub GetProcInfo()
Dim activeProcess As Process = GetActiveAppProcess()
With activeProcess
    ApplicationName = .MainModule.FileVersionInfo.FileDescription
    ProcessName = .ProcessName
    WindowTitle = .MainWindowTitle
End With
End Sub
  • Which information exactly do you have, and which information exactly do you want? – AHeyne Nov 13 '20 at 06:49
  • You are aware that the code you are referring was written for VB.Net, not VBA? – FunThomas Nov 13 '20 at 07:24
  • I need the current active program name. ex: If a mail is opened I need it to give me a string which says it's Outlook, if a excel file is open I need the outcome string to be Excel. Yes this code is a .Net code, but I need a VBA code for this to run in MS Access. – Nishan Gunarathne Nov 13 '20 at 22:10

0 Answers0