Hi all. I'm trying to access data from a password protected website. The first step is to log into the website which is what I'm struggling with. This is my first time ever using VBA so I scraped together some information online over the past hour and a half and put this together.
Sub test()
' open IE, navigate to the desired page and loop until fully loaded
Set ie = CreateObject("InternetExplorer.Application")
my_url = "sample url"
With ie
.Visible = True
.Navigate my_url
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not ie.Busy And ie.ReadyState = 4
DoEvents
Loop
End With
' Input the userid and password
ie.Document.getElementById("#user").Value = "sampleusername"
ie.Document.getElementById("#pwd").Value = "samplepassword"
' Click the "Search" button
ie.Document.getElementById("#loginform").Click
Do Until Not ie.Busy And ie.ReadyState = 4
DoEvents
Loop
End Sub
Anyways, it pops up with an objects required error. This code works for some other websites, I've tried it; however for the site i need to draw data from it doesn't seem to input anything into the username and password. I can't get it to interact with the website for some reason.
Any ideas?
Bookmarks