Hello all,
I am trying to create a macro that fetches information from a password protected site. I am getting error 438 but don't know how to fix it. At the moment, I am unable to automate the log in process.
I tried checking the page's source code for the property but I'm not sure what I'm looking for.
Here's my code at the moment.
Private Sub WebQuery()
Const READYSTATE_COMPLETE As Long = 4
Dim x As Integer
Dim UserName1 As String
Dim Password1 As String
UserName1 = InputBox("Enter your EnergyStar Portfolio Manager username")
Sheet1.Range("A78") = UserName1
Password1 = InputBox("Enter your EnergyStar Portfolio Manager password")
Sheet1.Range("A79") = Password1
URL = "http://www.energystar.gov/index.cfm?c=evaluate_performance.bus_portfoliomanager"
Set ie = Sheet1.WebBrowser1
ie.Visible = 1
DoEvents
ie.Navigate URL
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
With ie.Document
.Item("htmuserid").Value = Sheet1.Range("A78")
.Item("htmpassword").Value = Sheet1.Range("A79")
.submit
End With
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
'Application.Wait Now + TimeValue("00:00:05")
'HTMLdata = ie.Document.documentelement.innertext
'HTMLdata = VBA.Split(HTMLdata, Chr(13)) 'change the split as required CHR(13) is for carriage return.
'For x = 0 To UBound(HTMLdata)
'Sheet1.Range("A" & (x + 1)) = HTMLdata(x)
'Next x
End Sub
Thanks
I am trying to create a macro that fetches information from a password protected site. I am getting error 438 but don't know how to fix it. At the moment, I am unable to automate the log in process.
I tried checking the page's source code for the property but I'm not sure what I'm looking for.
Here's my code at the moment.
Private Sub WebQuery()
Const READYSTATE_COMPLETE As Long = 4
Dim x As Integer
Dim UserName1 As String
Dim Password1 As String
UserName1 = InputBox("Enter your EnergyStar Portfolio Manager username")
Sheet1.Range("A78") = UserName1
Password1 = InputBox("Enter your EnergyStar Portfolio Manager password")
Sheet1.Range("A79") = Password1
URL = "http://www.energystar.gov/index.cfm?c=evaluate_performance.bus_portfoliomanager"
Set ie = Sheet1.WebBrowser1
ie.Visible = 1
DoEvents
ie.Navigate URL
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
With ie.Document
.Item("htmuserid").Value = Sheet1.Range("A78")
.Item("htmpassword").Value = Sheet1.Range("A79")
.submit
End With
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
'Application.Wait Now + TimeValue("00:00:05")
'HTMLdata = ie.Document.documentelement.innertext
'HTMLdata = VBA.Split(HTMLdata, Chr(13)) 'change the split as required CHR(13) is for carriage return.
'For x = 0 To UBound(HTMLdata)
'Sheet1.Range("A" & (x + 1)) = HTMLdata(x)
'Next x
End Sub
Thanks