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
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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