Hi I'm trying to figure out a way to call a java script mapped to a button using VBA as part of the web page data entry automation. Following is the code from the site and also the code that I'm working on.
Browser code :
<input name="reportIIS" value="Select" class="button" onclick="javascript: onSelect('/cooapp/servlet/CooMainServlet?command=SelectProgram&programType=IIS')" type="button">
VBA
Sub login() 'this is working
Const Url$ = "https://www.mast-technicalservices.com/ecp/index2.jsp"
Dim UserName As String, Password As String, LoginData As Workbook, elems As Object
UserName = ThisWorkbook.Sheets("Sheet1").Range("B1")
Password = ThisWorkbook.Sheets("Sheet1").Range("B2")
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
With ie
.navigate Url
ieBusy ie
.Visible = True
Dim oLogin As Object, oPassword As Object
Set oLogin = .document.getElementsByName("ecp_param_userId")(0)
Set oPassword = .document.getElementsByName("ecp_param_password")(0)
oLogin.Value = UserName
oPassword.Value = Password
.document.forms(0).submit
ieBusy ie
Application.Wait (Now + TimeValue("0:00:02"))
' After 2sec wait time I need to click the said button to navigate to the next page
End With
End Sub
Sub ieBusy(ie As Object)
Do While ie.Busy Or ie.readyState < 4
DoEvents
Loop
End Sub