Using VBA To Automate IE and input user name, password, and hit submit

Slape

New Member
Joined
Oct 23, 2008
Messages
49
I'm trying to use VBA to go to a website that requires a User Name, Password, and a Submit Button.

So far I can get everything to work besides the Submit part. The code runs without errors, but doesn't actually "hit" the submit button on the webpage.

For posting, I removed my actual user name and password and and used the generic "User Name" and "Password" highlighted in blue.

I highlighted another section in green that I took from a previous post hoping it would solve my problem. The link is: http://www.mrexcel.com/forum/showthread.php?t=317060&highlight=vba+internet+explorer+submit


Here is the code I am using:

Sub GoToWebSiteAndPlayAroundNew()

Dim appIE As Object ' InternetExplorer.Application
Dim URL As String



Set appIE = CreateObject("InternetExplorer.Application")
URL = "https://efolio.morgankeegan.com/escripts/defaultLogon.asp?errCode=2"


With appIE
.navigate URL
.Visible = True

Do While .busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop


.document.getelementbyid("fUserName").Value = "UserName"
.document.getelementbyid("fPassword").Value = "Password"


End With


On Error Resume Next
x = 0
For Each mitem In IE.document.all
mitem.Value = "x"
x = x + 1
Next


x = 0
For Each mitem In IE.document.all
If x = "Submit" Then
mitem.Click
Exit For
End If

Next


End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Pedie

If you look at the source code of either page you should be able to find what you need.
 
Upvote 0
Norie, I did check it out but could not get it...

I found username = vb_login_username
and password = vb_login_password
but cant find submit button name...

?:(?

Thanks again
 
Upvote 0
pedie

Is there a specific URL you want to do this for?

You mentioned 'practice', but you can't really do that for this sort of thing.

Anyway for FaceBook the ids for the email and password are simply 'email' and 'pass'.

The login button id is uXXXXXX_X, where X is a digit.

I've not posted the actual digits because I think it might be randomly generated.

Not sure about that though.
 
Upvote 0
Great! thanks Norie...
I still cant find for this forum...I mean the submit button, sorry:)

Pedie
 
Upvote 0
Pedie

How are you checking the source code?

By the way, can't you 'practice' on another site?

Oh, almost forgot - the digits for the id for the login button on Facebook are random.
 
Upvote 0
How are you checking the source code?

By the way, can't you 'practice' on another site?

Oh, almost forgot - the digits for the id for the login button on Facebook are random.


Okay Norie, thanks for letting me know about that...
Here is another link i log on to everyday maybe I can automate this if you help me::)https://login.yahoo.com/config/login_verify2?&.src=ym&rl=1


I view the source code my right clicking on the webpage and then click on "View Source" is that the same thing I need to follow?

I just dont know how to identify which letter or letter can mean that it is submit button....:)


Thanks again!


PS: Is there a way of identifying these things? for example what is what[clickable button, password text box etc?]
 
Last edited:
Upvote 0
pedie

Please start a new thread for your own questions.

Posting in an existing thread can confuse people, and even put people off answering your question.:)
 
Upvote 0
Okay Norie, thanks again...this a great learning...
Though i dont actually understand it completely I now know this can be done!:)
 
Upvote 0
Hi Norie, I know that the above thread is quite old however, my need for answers is about to drive me batty! I have been searching for a way to automate date entry process from excel to webform. I can get the macro to navigate to the website "http://www.themightygiant.com/cm/index" but can't figure out the code to populate the 'popover' webform. not sure if you or anyone else can help but I'm running out of options. Can anyone help?

I'm Youtubed Out!!!
 
Upvote 0

Forum statistics

Threads
1,223,757
Messages
6,174,322
Members
452,555
Latest member
colc007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top