hteel
asked on
Auto-populate a web form and click the command button
I need to write VB code that will populate a form on the web and click the command button. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Place a textbox on your form with the mulitline property set on true and use the following code :
Private Sub Form_Load()
Dim IE
Set IE = CreateObject("InternetExpl orer.Appli cation")
IE.Navigate "http://ssdi.genealogy.rootsweb.com/cgi-bin/ssdi.cgi"
IE.Visible = True
While IE.Busy
DoEvents
Wend
IE.Document.All("ssn").Val ue = "My Social Security Nbr" ' contains the HTML name of the object
IE.Document.All("submit"). Click ' contains the HTML name of the object
While IE.Busy
DoEvents
Wend
Str1 = IE.Document.body.innerhtml
While IE.Busy
DoEvents
Wend
Text1 = Str1
End Sub
Hope it works for you, i couldn't test it because the query doesn't return records.
Happy Programming,
Ayhan Elatik
Private Sub Form_Load()
Dim IE
Set IE = CreateObject("InternetExpl
IE.Navigate "http://ssdi.genealogy.rootsweb.com/cgi-bin/ssdi.cgi"
IE.Visible = True
While IE.Busy
DoEvents
Wend
IE.Document.All("ssn").Val
IE.Document.All("submit").
While IE.Busy
DoEvents
Wend
Str1 = IE.Document.body.innerhtml
While IE.Busy
DoEvents
Wend
Text1 = Str1
End Sub
Hope it works for you, i couldn't test it because the query doesn't return records.
Happy Programming,
Ayhan Elatik
aelatik, What does these two lines mean ? Would you please explain to me ?
IE.Document.All("ssn").Val ue = "My Social Security Nbr" ' contains the HTML name of the object
IE.Document.All("submit"). Click ' contains the HTML name of the object
I would like to access the textfield in the form . Is it a way to locate the textfield in the form in the homepage ?
IE.Document.All("ssn").Val
IE.Document.All("submit").
I would like to access the textfield in the form . Is it a way to locate the textfield in the form in the homepage ?
Yes, It will give the textfield named "ssn" the value "My social Security Nbr" and click on the button named "submit"
aelatik , would you please take a look on my question ? I think you must know how to answer it. The link is here :
https://www.experts-exchange.com/questions/20781860/Internet-Explorer-Object-and-Automation-and-Access-the-DOM-structure.html#9644691
Thanks.
https://www.experts-exchange.com/questions/20781860/Internet-Explorer-Object-and-Automation-and-Access-the-DOM-structure.html#9644691
Thanks.
ASKER
aelatik,
I pulled a random SSN off of this site so that I could test and when I did it failed on the "IE.Document.All("submit") .Click" line of code. I got a run-time error 438 Object doesn't support this property or method.
Below is your code with a legit SSN inserted. Any advice why it fails?
Thanks!
Private Sub Form_Load()
Dim IE
Set IE = CreateObject("InternetExpl orer.Appli cation")
IE.Navigate "http://ssdi.genealogy.rootsweb.com/cgi-bin/ssdi.cgi"
IE.Visible = True
While IE.Busy
DoEvents
Wend
IE.Document.All("ssn").Val ue = "450875872" ' contains the HTML name of the object
IE.Document.All("submit"). Click ' contains the HTML name of the object
While IE.Busy
DoEvents
Wend
Str1 = IE.Document.body.innerhtml
While IE.Busy
DoEvents
Wend
Text1 = Str1
End Sub
I pulled a random SSN off of this site so that I could test and when I did it failed on the "IE.Document.All("submit")
Below is your code with a legit SSN inserted. Any advice why it fails?
Thanks!
Private Sub Form_Load()
Dim IE
Set IE = CreateObject("InternetExpl
IE.Navigate "http://ssdi.genealogy.rootsweb.com/cgi-bin/ssdi.cgi"
IE.Visible = True
While IE.Busy
DoEvents
Wend
IE.Document.All("ssn").Val
IE.Document.All("submit").
While IE.Busy
DoEvents
Wend
Str1 = IE.Document.body.innerhtml
While IE.Busy
DoEvents
Wend
Text1 = Str1
End Sub
Hteel,
I don't know what has gone wrong but a copyied the code and it works with me...
I don't know what has gone wrong but a copyied the code and it works with me...
"IE.Document.All("submit") .Click" can only cause problems if it doesn't exist in the HTML document or woth a different name. Beware that "IE.Document.All("submit") .Click", submit is the name of the button.
ASKER
hmmm.....thanks for responding....at least I know it's not something wrong with the code if it is working for you....must be something wrong with my version of VB....thanks again!
ASKER
Private Sub Form_Load()
Dim IE
Set IE = CreateObject("InternetExpl
IE.Navigate "http://ssdi.genealogy.rootsweb.com/cgi-bin/ssdi.cgi"
IE.Visible = True
While IE.Busy
DoEvents
Wend
IE.Document.All("ssn").Val
IE.Document.All("submit").
End Sub