INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VBA autofill html forms

VBA autofill html forms

(OP)
I am trying to automate the completion and submission of a series of html forms in VBA. I am able to open the login form, automate the completion of the userID and Password fields as well as check a "disclosure" type checkbox, and clicking the submit button, which brings me to form 2. form 2 has no data to complete, All I need to do is click a button on form 2. I can't get that button to fire for anything. Consistent error 424 or error 91 and I have commented those problems in the code below.

So I am new to this, and really don't know what I am doing, but I am thinking its because I am not actually on form 2 when I reach the code trying to click . Though when the code reaches ieapp.visable = true I do get form1, then form 2 visable, I feel like ieapp may still be pointing to form 1, because when I add iapp.refresh, I am back to form 1, with no info in the userid and password fields of form 1. It seems to me that form 1 has been refreshed.

Here's the form 2 button I want to click: <input name="enterERE" class="uef-btn" id="enterere" type="submit" value="Enter ERE">

Here's my VBA code :

Private Sub ERE_Reports_Click()
Dim ieApp As InternetExplorer
Dim iePage As HTMLDocument
Dim Btn As HTMLFormElement

Set ieApp = New InternetExplorer
ieApp.Navigate "https://secure.ssa.gov/acu/LoginWeb/loginHandler.d..."

'wait for page to load
Do Until ieApp.ReadyState = READYSTATE_COMPLETE
Loop

iePage.Forms(0).Item("userid").Value = "UserID"
iePage.Forms(0).Item("password").Value = "Password"
iePage.Forms(0).Item("accept").Click
iePage.Forms(0).submit

Do Until ieApp.ReadyState = READYSTATE_COMPLETE
Loop
ieApp.Visible = True

'this means I am back on form 1 with no info in the userid and password fields
ieApp.Refresh2

'render error 13
Set Btn = iePage.getElementsByName("enterERE")
Btn.Click
'renders error 91
iePage.getElementsByName("EnterERE").Item.Click
'renders error 91
iePage.getElementById("enterere").Click
'iePage.getElementsByClassName("uef-btn").Item.Click
'renders error 424
iePage.Forms(0).Item("enter ere").Click
'render error 438
iePage.getElementsByTagName("enterERE").Click


End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close