Hello all,
Hope you can help with my problem.
This is my first post on a forum, so please forgive me if I've put this in the wrong place.
At my place of work there are many different systems and places where information is stored and part of my job is to collate that info into one place, so that the managers have one place they go to for reports on how the department is running etc etc.
The only tool we have at our disposal to undertake this task is MS Access, so over the years we've become fairly proficient with VBA.
However our phone system recently changed and I have come across a new problem that has me vexed. In order to get stats out of the new system I have to open a webpage, select all departments, enter yesterdays date, hit download, save a S/S then import it to a table
All terribly manual and time consuming.
I was recently made aware of API and have tried to incorporate this into a form.
So far when I click the command button, it opens the webpage, next I need to send an enter key press in order to login, but it doesn't work.
This is what I have in code
Private Sub Command4_Click()
Dim x, result
x = FindWindow(vbNullString, "Active Portal - [Login Screen]")
Call SendMessageLong(x, WM_CHAR, 13, 0&)
Call PostMessage(x, WM_KEYDOWN, VK_RETURN, 0&)
End Sub
And in a module
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_CHAR = &H102
Public Const BM_CLICK = &HF5
Public Const BM_SETSTATE = &HF3
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const VK_RETURN As Long = &HD
Hope you can help with my problem.
This is my first post on a forum, so please forgive me if I've put this in the wrong place.
At my place of work there are many different systems and places where information is stored and part of my job is to collate that info into one place, so that the managers have one place they go to for reports on how the department is running etc etc.
The only tool we have at our disposal to undertake this task is MS Access, so over the years we've become fairly proficient with VBA.
However our phone system recently changed and I have come across a new problem that has me vexed. In order to get stats out of the new system I have to open a webpage, select all departments, enter yesterdays date, hit download, save a S/S then import it to a table
All terribly manual and time consuming.
I was recently made aware of API and have tried to incorporate this into a form.
So far when I click the command button, it opens the webpage, next I need to send an enter key press in order to login, but it doesn't work.
This is what I have in code
Private Sub Command4_Click()
Dim x, result
x = FindWindow(vbNullString, "Active Portal - [Login Screen]")
Call SendMessageLong(x, WM_CHAR, 13, 0&)
Call PostMessage(x, WM_KEYDOWN, VK_RETURN, 0&)
End Sub
And in a module
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_CHAR = &H102
Public Const BM_CLICK = &HF5
Public Const BM_SETSTATE = &HF3
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const VK_RETURN As Long = &HD