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 
3
  • Which information exactly do you have, and which information exactly do you want? Commented Nov 13, 2020 at 6:49
  • You are aware that the code you are referring was written for VB.Net, not VBA? Commented Nov 13, 2020 at 7: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. Commented Nov 13, 2020 at 22:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.