Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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: </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" </td </tr <tr <td colspan="3" </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();" <i nput class="form_b" type="reset" value="Limpar" name="limpar"</td </tr <tr <td colspan="3"<strong<font color="#FF6600" </font</strong</td </tr <tr <td colspan="3"<strong<font color="#FF6600" </font</strong</td </tr </table <br/ </form Thanks Again!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel values to Website, HTML extraction back to Excel. PLEASEHelp!!! | Excel Programming | |||
For a website, are Excel scripts better than other programming language scripts? | Excel Programming | |||
Excel Macro - Extract data from website | Excel Programming | |||
Excel data showing up like html language | Excel Discussion (Misc queries) | |||
Copying HTML Data From Website problem | Excel Discussion (Misc queries) |