VBA - Login to Webpage that contains textbox without ID

asinoastuto1

New Member
Joined
Dec 4, 2013
Messages
5
All:

First and foremost I just want to say how vital this website is as a tool for someone who is trying to learn without a formal programming education. I have been lurking on this site for months now and in that time I have learned enough to actually start writing my own codes. After reading up on a lot of forums about this given issue, I have resorted to finally posting for myself.

Now comes the part I need help with.

Scenario:

I need to login to a website so that I could automatically pull a file which is updated every hour or so. (Only need help on the actual login process)

Some catches:

1) There are no ID's on any of the text boxes or buttons which I need to access
2) This is a secure (https://) website that only computers from my network can access.

Pertinent Information:
Link (wont help much)
HTML:
https://clientxfer.adp-ics.com/cehttp/html/main.htm

Below is a screen shot of the website.

SECURE.png


HTML:
<form name="form1" method="post" action="/cehttp/servlet/MailboxServlet">			<INPUT TYPE="HIDDEN" NAME="operation" VALUE="LOGON">              <table width="100%" border="0" cellspacing="0" cellpadding="0">                <tr>                   <td align="center" valign="top" class="copy">                     <p class="copy990000"><strong>To                       logon to Connect:Enterprise base,                       fill in the fields below and click                       Logon</strong></p>                    <table border=0 cellpadding=0 cellspacing=5>                      <tr valign="middle">                         <td class="copySmall" nowrap height="30" align="right"><b>                           User ID </b></td>                        <td class="copySmall" nowrap height="30">                           <input type="TEXT" name="remote" size="24" maxlength="64" class="copySmall">                        </td>                      </tr>                      <tr valign="middle">                         <td class="copySmall" nowrap height="30" align="right"><b>                           Password </b></td>                        <td class="copySmall" nowrap height="30">                           <input type="PASSWORD" name="password" size="24" maxlength="16" class="copySmall">                        </td>










Above is the HTML of the given website(not the whole HTML just the relevant lines). The login box is named "remote" and the password box is named "password". In order to login I do not need to input anything into the "server" box. Also, it seems as if the text boxes are located on "form1".



So can anyone give me some assistance or point me in the right direction? I know this will be difficult as no one can test it besides me (given that I am the only one who can access the website), but any help will be greatly appreciated.
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You should be able to get the password/logon fields by using their names.

For example.
Code:
Dim frm As Object
Dim pwd As Object

    Set frm = IE.documents.forms("Form1") ' or forms(0)

    Set pwd = frm.all("password")

'or 

    Set pwd = frm.elements("password")

'or 

    Set pwd = frm("password")


    If Not pwd Is Nothing Then
        pwd.Value = "thepassword"
        frm.submit
    End If
 
Upvote 0
Code:
Sub NORIEEEE()

Dim frm As Object
Dim pwd As Object
Dim ie As InternetExplorer


Set ie = New InternetExplorer
    ie.Visible = True
    
    ie.navigate "https://clientxfer.adp-ics.com/cehttp/html/main.htm"
    
    Do While ie.Busy: DoEvents: Loop
    Do Until ie.readyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    Set frm = ie.documents.forms("Form1") ' or forms(0) <--- ERROR '438': Object dosnt support this property or method


    Set pwd = frm.all("password")


'or


    Set pwd = frm.elements("password")


'or


    Set pwd = frm("password")




    If Not pwd Is Nothing Then
        pwd.Value = "thepassword"
        frm.submit
    End If




End Sub

I have tried something similar to this prior to posting and got the same error as I do now. I have tried both "form1" and forms(0) to no avail.
 
Upvote 0
Solved

Code:
Sub sofIELogin20080792()  Dim strUrl
  Dim IE, frm
  Set IE = CreateObject("InternetExplorer.Application")


  strUrl = "xxxxxxxx" 'website
    IE.Visible = True
  IE.Navigate strUrl
  Do While IE.readyState <> 4 Or IE.Busy = True
    DoEvents
  Loop
  '
  ' get the form object to input username and password:
  '
  Set frm = IE.document.getElementsByName("form1")(0)
  With frm(form1)
  frm.elements("remote").Value = "username"
  frm.elements("password").Value = "password"
  frm.submit
  End With
  Do While IE.readyState <> 4 Or IE.Busy = True
    DoEvents
  Loop
'


'
  Set frm = Nothing
  Set IE = Nothing
'
  MsgBox "User login has been tried."
'
End Sub

Norie, thank you so much for your help.
 
Upvote 0
Does the code I posted work if you fix the 'documents' typo?
 
Upvote 0
Norie,

I think the error came from me not accessing the right link. On the left hand side of the website there was a "Login" button that redirected you to the real login form which I needed to write to.

On another note, I have run into another issue.

Norie, should I create a new post to being this or should I just continue here?

The issue is stemming from after I am logged in to the FTP website, and when I go to download the file. I correctly download it but the document in repalced with text saying

R E D I R E C T I O N E X A M P L E This sample page shows how redirection may be made to work.


When a C:E HTTP session times out, or a user has not logged on, the
servlet looks for a page called MSG_NOT_LOGGED_ON.htm. If it does not exist,
it puts out its own message. If it does exist, it redirects to it.


This page demonstrates how a Java Script may be used to pop up an alert box,

then redirect the user back to the logon page.


^^ unfortunately the website is not letting me post the text that I am receiving from my downloaded file. Above is just a excerpt.


Again, if this should be posted to a fresh post let me know and I will write one up.<link href="icsappsStyle.css" rel="stylesheet" type="text/css"><link href="icsappsStyle.css" rel="stylesheet" type="text/css">
<link href="icsappsStyle.css" rel="stylesheet" type="text/css">
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,847
Members
452,361
Latest member
d3ad3y3

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