I have some excel VBA code that populates a public website with name, ssn and date of birth to check selective service registration. Once the information is entered the status of registration is returned. (the data i am using in the code is for example
purposes only and returns non-registraiton information). I want to capture that page (screen shot) in place in a file. I need to do this with multiple names that will be read from a spreadsheet.
The problem I have is that the code below returns a run time error of 424 and I cannot seem to resolve this error. Any suggestions to resolve this error?
Sub Test()
Dim IE As New InternetExplorer
Dim IEdoc As HTMLDocument
Dim Item As Variant
'Open IE and go to the site
IE.Visible = True
IE.navigate "https://www.sss.gov/RegVer/wfVerification.aspx"
'Wait until side it loaded
Do While IE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
'Get the body
Set IEdoc = IE.document
'Find each field and fill out
Item = IEdoc.getElementsByName("_ctl0:ContentPlaceHolder1:tbLastName")
Item.Value = "smith"
Item = IEdoc.getElementsByName("_ctl0:ContentPlaceHolder1:tbSSAN")
Item.Value = "123456789"
Item = IEdoc.getElementsByName("_ctl0:ContentPlaceHolder1:tbDOB")
Item.Value = "05121994"
IE.document.forms(0).Item("Submit1").Click
' grab the whole screen &amp;amp; paste into Excel
appIE.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
appIE.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
Workbooks.Add
ActiveSheet.Paste
Application.ScreenUpdating = True
appIE.Quit
End Sub