Sub Test()
Const cURL = "https://nes.ncdc.noaa.gov/sub-login.html"
Const cUser = "XXXX" 'REPLACE XXXX WITH YOUR USER ID
Const cPass = "YYYY" 'REPLACE YYYY WITH YOUR PASSWORD
Dim ie As Object
Dim doc As HTMLDocument
Dim PageForm As HTMLFormElement
Dim UserIdBox As HTMLInputElement
Dim PasswordBox As HTMLInputElement
Dim FormButton As HTMLInputButtonElement
Dim Elem As IHTMLElement
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate cURL
'Wait for initial page to load
Do While ie.busy: DoEvents: Loop
Set doc = ie.document
'Output HTML tags to debug window
Debug.Print "Login page: " & ie.LocationURL
For Each Elem In doc.all
'Debug.Print Elem.tagName
Next
'Get the only form on the page
Set PageForm = doc.forms(0)
'Get the User Id textbox
'< input class="TextBox" maxlength="8" name="userid" size="8">
Set UserIdBox = PageForm.elements("userid")
'Set the User Id
UserIdBox.Value = cUser
'Get the password textbox
'< input class="TextBox" type="password" maxlength="10" name="Password" size="12">
Set PasswordBox = PageForm.elements("password")
'Set the password
PasswordBox.Value = cPass
'Submit the form (like clicking the 'Submit' button) to navigate to next page
PageForm.submit
'Wait for the new page to load
Do While ie.busy: DoEvents: Loop
'Get the HTML document of the new page
Set doc = ie.document
'Output HTML tags to debug window to prove this is the new page
Debug.Print "Terms of Use page: " & ie.LocationURL
For Each Elem In doc.all
'Debug.Print Elem.tagName
Next
'The new page contains 'Terms of Use' conditions and an 'Accept' button within a form
'Get the only form on the page
Set PageForm = doc.forms(0)
'Get the form submit button and click it to navigate to next page
'< input type="submit" value="Accept" name="selection">
'Note: unlike the login page, can't use PageForm.submit to submit this form because it doesn't have
'a method="post" attribute
Set FormButton = PageForm.elements("selection")
FormButton.Click
'Wait for the new page to load
Do While ie.busy: DoEvents: Loop
'Get the HTML document of the new page
Set doc = ie.document
'Output HTML tags to debug window to prove this is the new page
Debug.Print "Main Pronto page: " & ie.LocationURL
For Each Elem In doc.all
'Debug.Print Elem.tagName
Next
End Sub
Sub VisitWebsite()
Const Hyper As String = "https://nes.ncdc.noaa.gov/sub-login.html"
ThisWorkbook.FollowHyperlink Address:=Hyper ',
NewWindow = True
End Sub