Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Excel VBA Macro to input data on website - problem with HTML language

Hello Everyone,

Im using the code below to successfully log on a website with username and password. However, after I log in, I need to fill a form with 6 input boxes, each with 4 digits, the 5th with 3 digits. Once I type (manually), the first 4 digits, it automatically goes to the next tab.

With the code below, I looked into the website HTML code (and looked for the "name" part of the login and password). But for these 6 boxes I cant get in to work using the same logic. My failed additions to the code are in bold and bigger size.

Running the code with my additions (see below) I get a type mismatch error 13.

I appreciate any help!

Sub Test()

Const cURL = "http://mail.google.com" 'Enter the web address here
Const cUsername = "XXXXXX" 'Enter your user name here
Const cPassword = "XXXXXX" 'Enter your Password here
Const cBox1 = "1234" ' This is my addition


Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
Dim SignInButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Dim qt As QueryTable
Dim Box1 As HTMLInputElement ' This is my addition


Set IE = New InternetExplorer

IE.Visible = True
IE.Navigate cURL

'Wait for initial page to load

Do While IE.ReadyState < READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop

Set doc = IE.Document

'Get the only form on the page

Set LoginForm = doc.forms(0)

'Get the User Name textbox and populate it
'input name="Email" id="Email" size="18" value="" class="gaia le val" type="text"

Set UserNameInputBox = LoginForm.elements("Email")
UserNameInputBox.Value = cUsername

'Get the password textbox and populate it
'input name="Passwd" id="Passwd" size="18" class="gaia le val" type="password"


Set PasswordInputBox = LoginForm.elements("Passwd")
PasswordInputBox.Value = cPassword

'Get the form input button and click it
'input class="gaia le button" name="signIn" id="signIn" value="Sign in" type="submit"

Set SignInButton = LoginForm.elements("signIn")
SignInButton.Click

'Wait for the new page to load

Do While IE.ReadyState < READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop

Set Box1 = LoginForm.elements("intermedica") ' This is my addition
Box1.Value = Box1 ' This is my addition


End Sub






Here is the HTML code that I cant figure out:

<td align="right" valign="baseline"Carteirinha:&nbsp;</td
<td colspan="2"
<input type="text" size="4" maxlength="4" class="form" name="intermedica" onKeyUp="return autoTab(this,4,event);"
<input type="text" size="4" maxlength="4" class="form" name="intermedica" onKeyUp="return autoTab(this,4,event);"
<input type="text" size="4" maxlength="4" class="form" name="intermedica" onKeyUp="return autoTab(this,4,event);"
<input type="text" size="4" maxlength="4" class="form" name="intermedica" onKeyUp="return autoTab(this,4,event);"
<input type="text" size="3" maxlength="3" class="form" name="intermedica" onKeyUp="return autoTab(this,3,event);"
<input type="text" size="4" maxlength="4" class="form" name="intermedica"&nbsp;&nbsp;&nbsp;
</td
</tr
<tr
<td colspan="3"&nbsp;</td
</tr
<tr
<td colspan="3" align="center"<input class="form_b" id="act_B" type="button" value="Buscar" name="act_B" onClick="javascript:PesquisaAss();"&nbsp;&nbsp;<i nput class="form_b" type="reset" value="Limpar" name="limpar"</td
</tr
<tr
<td colspan="3"<strong<font color="#FF6600"&nbsp;&nbsp;</font</strong</td
</tr

<tr
<td colspan="3"<strong<font color="#FF6600"&nbsp;</font</strong</td
</tr




</table
<br/

</form



Thanks Again!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Excel VBA Macro to input data on website - problem with HTML language

In message of Thu, 4 Oct 2012
23:17:05 in microsoft.public.excel.programming, Excel_Phil <Excel_Phil.a
writes

Hello Everyone,

Im using the code below to successfully log on a website with username
and password. However, after I log in, I need to fill a form with 6
input boxes, each with 4 digits, the 5th with 3 digits. Once I type
(manually), the first 4 digits, it automatically goes to the next tab.

With the code below, I looked into the website HTML code (and looked for
the "name" part of the login and password). But for these 6 boxes I cant
get in to work using the same logic. My failed additions to the code are
in bold and bigger size.


[snip]

I use DebugBar from
http://www.debugbar.com/ for such problems. It has a
control, which can be put over any part of an IE screen and displays
relevant information.
Once I know what it is, I can usually work out how to access it from
VBA. YMMV
--
Walter Briscoe
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel values to Website, HTML extraction back to Excel. PLEASEHelp!!! snwskier2 Excel Programming 0 October 29th 09 05:28 PM
For a website, are Excel scripts better than other programming language scripts? Advice Pro[_3_] Excel Programming 13 May 31st 09 05:11 AM
Excel Macro - Extract data from website Icy Excel Programming 0 January 9th 08 02:39 PM
Excel data showing up like html language Beach Lover Excel Discussion (Misc queries) 3 August 28th 07 06:43 PM
Copying HTML Data From Website problem Smish Excel Discussion (Misc queries) 1 February 20th 07 04:11 PM


All times are GMT +1. The time now is 06:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"