Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another VBA Logging into Website question

Status
Not open for further replies.

lnfinite

Technical User
Dec 21, 2010
2
US
I need some help. I've seen this question asked in several different ways on this forum, but I've been unable to successfully implement any of the suggestions.

I'm trying to automate some tedious logins to certain webpages I use everyday. I've gotten it to where I can navigate to the webpage, and enter my ID and PW into their respective boxes, but I'm stuck trying to figure out how to click the submit button. I've tried multiple methods, but I'm obviously missing something.

I've got my login credentials stored in an excel spreadsheet, and I'm calling them from that worksheet. The login page has 2 buttons at the bottom. The SIGN ON button and the CHANGE PW button. Crazy thing is BOTH are named action.

LOGIN BUTTON = input type="submit" value="Sign On" name="action"
CHG PW BUTTON = input type="submit" value="Change Password" name="action"

Maybe I should be trying to figure out the buttons Element ID, but I just cant get my head around everyones SIMPLE instructions on identifying Element IDs.

Here is part of the code I'm using now.

Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Sub SVP()
'Open site if it requires a PassWord Model!
Dim ie As Object
Dim uLogin As String
Application.ScreenUpdating = False
Sheets("UserPassword").Select
uLogin = Range("D22").Value
Sheets("Launcher").Select
Dim uPass As String
Application.ScreenUpdating = False
Sheets("UserPassword").Select
uPass = Range("E22").Value
Sheets("Launcher").Select

Dim oHTML_Element As IHTMLElement
Dim sURL As String


sURL = "Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.navigate sURL
oBrowser.Visible = True

Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE

Set HTMLDoc = oBrowser.document

HTMLDoc.all.UserId.Value = uLogin
HTMLDoc.all.Password.Value = uPass
HTMLDoc.all.submit.Click

End Sub


Here is the HTML for the page.

 
<!-- Sign-on table -->
<!-- svp 232 <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=580> -->
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<FORM METHOD="POST"
ACTION="/svp/servlet/SignonServlet"
NAME="signon" onSubmit="return handleSubmit(this);" autocomplete="off">
<!-- body content -->

<tr>
<td><img src="/Img/pixel.gif" width="30" height="1" alt="" border="0"></td>
<td><img src="/Img/pixel.gif" width="200" height="1" alt="" border="0"></td>
<td><img src="/Img/pixel.gif" width="15" height="1" alt="" border="0"></td>
<td width="100%"><img src="/Img/pixel.gif" width="1" height="1" alt="" border="0"></td>
<td><img src="/Img/pixel.gif" width="30" height="1" alt="" border="0"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3"><h1>Sign On</h1></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3"><img src="/Img/pixel.gif" width="1" height="15" alt="" border="0"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td nowrap class="textreq">User ID</td>
<td nowrap>&nbsp;</td>
<td nowrap><input type="text" name="userid" size="8" maxlength="8"
onFocus="window.status='Enter User ID';return true">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td nowrap class="textreq">Password</td>
<td nowrap>&nbsp;</td>
<td nowrap><input type="password" name="password" size="8" maxlength="8"
onFocus="window.status='Enter User Password';return true">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><img src="/Img/pixel.gif" width="1" height="15" alt="" border="0"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td class="text3" colspan="3">XYZ Platform requires a valid User ID and Password.<br>
If you do not have one, please see your Security Officer.</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><img src="/Img/pixel.gif" width="1" height="15" alt="" border="0"></td>
</tr>

<tr>
<td>&nbsp;</td>
<td><img src="/Img/pixel.gif" width="1" height="20" alt="" border="0"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td nowrap colspan="2">&nbsp;</td>
<td nowrap><input type="submit" value="Sign On" name="action"
onFocus="window.status='Click here to go to the Main Menu';return true"><img
src="/Img/pixel.gif" width="5" height="1" border="0"><input type="submit" value="Change Password"
name="action"
onFocus="window.status='Click here to change your User Password';return true"></td>
</tr>
</table>
</form>

<table cellspacing="0" cellpadding="0" border="0" width="100%">
<!-- footer table-->
<tr>
<td colspan="9" bgcolor="#666600"><img src="/Img/pixel.gif" width="1" height="1" alt="" border="0"></td>
</tr>

</table>
<SCRIPT>
document.signon.userid.focus();
</SCRIPT>
</body>
</html>



Any help would be appreciated
 
Well no suggestions from anyone so I just had to use a quick and dirty method to submit.

SendKeys "{ENTER}", True


I would like to have been able to figure out how to get the script to submit it via the button, but I guess this will do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top