Logon to website...almost there

whose2know

Board Regular
Joined
May 1, 2002
Messages
59
I'm trying to update code that I've used for years to logon to websites to get information. I've used sendkeys to transfer IDs/Passwords to sites for years, and it still works, but thought I would get the code current. I use XL2007 and I've searched on the board and can pass the password and ID to the site, but I can't get the "Sign In" button to click. All help is appreciated. Here's the code I'm working with now:

Sub LO()

Set objIE = CreateObject("InternetExplorer.Application")

With objIE
.navigate "http://www.duke-energy.com/north-carolina.asp" ' sign on page
.Visible = 1
Do While .busy: DoEvents: Loop
Do While .readystate <> 4: DoEvents: Loop
Set htmlDoc = .document
Set htmlColl = htmlDoc.getElementsByTagName("INPUT")
For Each htmlInput In htmlColl
If htmlInput.Name = "userId" Then _
htmlInput.Value = "myID"
If htmlInput.Name = "userPassword" Then _
htmlInput.Value = "myPW"
Next htmlInput
Do While .readystate <> 4: DoEvents: Loop
For Each htmlInput In htmlColl
If htmlInput.Name = "signin_btn" Then
htmlInput.Click ' CANT GET TO CLICK BUTTON
Exit For
End If
Next htmlInput
End With
End Sub
 

whose2know

Board Regular
Joined
May 1, 2002
Messages
59
OK, I figured this step out the click code. It was:

If htmlInput.Name = "" Then
htmlInput.Click ' go to upload page


But now I have two easier questions.

1> How do I paste a string of data into the website and
2> once the data loads, how do I copy the data on the page back into excel?

Here's part of the code I'm trying to use:

For Each htmlInput In htmlColl
If htmlInput.Name = "Mode" Then _
htmlInput.Value = "PasteString"
Next htmlInput

Here's some of the source code from the site (that shows the "Mode" input tag). I can't get it to put any value into the website, but I can get the "continue" button to click.


<div class="content">
<h2>Customer Billing Information - Input Accounts</h2>

<input type="hidden" name="Mode" value="1">
<div class="instructions">

<p>
Please add or copy and paste up to 25 account(s) and zip code(s) into <br/>
the area provided below.
<br/><br/>
<span style="color: red;font-weight: bold;">APPLICATION ACCEPTS CAROLINAS ACCOUNTS ONLY.</span>
<br/><br/>
<span class="bold">Note: </span>Please enter one account and one zip code per line
and separate <br/> the account number and the zip code with a comma as follows:
<br/><br/>
<span class="bold">Example: </span>12345789,28203
<br/><br/>
</div>
<div class="textArea">
<textarea name="accounts" rows="10" cols="40"></textarea>
</div>
<div class="buttons" >
<table>
<tr>
<td valign="top">
<input type="button" name="Continue" value="Continue" onclick="javascript:execContinue()" > 
<input type="button" name="Cancel" value="Cancel" onclick="javascript:execCancel()" >
</td>
<td valign="top" style="padding : 0px, 0px, 10px, 10px">
<script type="text/javascript">
progressbar= createBar(200,22,'white',1,'black','blue',125,7,3,"");

Any help is appreciated
 

Forum statistics

Threads
1,084,859
Messages
5,380,326
Members
401,665
Latest member
iahmad

Some videos you may like

This Week's Hot Topics

Top