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,081,774
Messages
5,361,219
Members
400,617
Latest member
barron1

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top