asked on
Private Sub pullData_Click()
'Declare the variable for Internet Explorer
Dim IE As SHDocVw.InternetExplorer
Set IE = New InternetExplorer
Dim myURL As String
IE.Visible = True
'Impact Radius URL
myURL = "https://app.impact.com"
'set the username variable to be put into the website
Dim impactRadiusUserName As String
impactRadiusUserName = Sheet1.Range("impactRadiusUn").Value
'Go to the URL
IE.navigate myURL
Do
Loop Until IE.readyState = READYSTATE_COMPLETE
'This code allows to look through the HTML code in the website document
'for the variables (username and password)
Dim IEdoc As MSHTML.HTMLDocument
Dim elementId As String
Dim HTMLInput As MSHTML.IHTMLElement
Set IEdoc = IE.document
elementId = "j_username"
' IEdoc.forms("login").elements("j_username").Value = "TEST"
'Getting the element by ID so we can input the username
Set HTMLInput = IEdoc.getElementById(elementId)
HTMLInput.Value = "TEST@Gmail.com"
End Sub
ASKER
Visual Basic for Applications (VBA) enables building user-defined functions (UDFs), automating processes and accessing Windows API and other low-level functionality through dynamic-link libraries (DLLs). VBA is closely related to Visual Basic and uses the Visual Basic Runtime Library, but it can normally only run code within a host application rather than as a standalone program. It can, however, be used to control one application from another via OLE Automation. VBA is built into most Microsoft Office applications.
TRUSTED BY
ASKER
IEdoc.forms("login").eleme
That did not work and I was still getting the same error. I finally found a workaround by implementing some error handling and running the code again when the error occurs via a loop. Please see below:
Open in new window
I don't think this is the best way of dealing with this issue though. Does someone have a better idea that works better than this?