I have created a UserForm which consist of Textbox’s and Commandbutton’s . For one Textbox, it’s purpose is for entering account number information such as: 100200300. After entering the account number in the Textbox, I wont it to then be inserted into a Webpage HTMLInputBox. Then by clicking on the Commandbutton, I would like for it to access the account from the webpage. Now I have created a code to do this but the only problem, I don’t want the code to create a new webpage. Instead, I would like the code to select the existing webpage or document that I already have opened. Lets use the web page for Yahoo Mail as an example for the code. https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym. This page consist of a Yahoo ID, Password, CheckBox, then a Sign In Button. The Yahoo page source code.
For the HTMLInputBox, "input name='login' id='username' maxlength='96' tabindex='1' value=''"
For the next HTMLInputBox, "input name='passwd' id='passwd' type='password' maxlength='64' tabindex='2'"
For the Submit Button, "button type='submit' id='.save' name='.save' class='secondaryCta' tabindex='5'"
Here’s the code I’m currently using. Remember, I’m not looking to create at new webpage but to access the current webpage I’ve currently pulled up.
Private Sub CommandButton8_Click()
Const cURL = “https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym”
Dim IE As Object
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim SignInButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Set IE = CreateOject(“InternetExplorer.Application”)
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)
Set UserNameInputBox = LoginForm.elements("username")
UserNameInputBox.Value = TextBox17.Text
Set SignInButton = LoginForm.elements(".save")
SignInButton.Click
'Wait for the new page to load
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
'Get the HTML document of the new page
Set doc = IE.document
End Sub
For the HTMLInputBox, "input name='login' id='username' maxlength='96' tabindex='1' value=''"
For the next HTMLInputBox, "input name='passwd' id='passwd' type='password' maxlength='64' tabindex='2'"
For the Submit Button, "button type='submit' id='.save' name='.save' class='secondaryCta' tabindex='5'"
Here’s the code I’m currently using. Remember, I’m not looking to create at new webpage but to access the current webpage I’ve currently pulled up.
Private Sub CommandButton8_Click()
Const cURL = “https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym”
Dim IE As Object
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputElement
Dim SignInButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Set IE = CreateOject(“InternetExplorer.Application”)
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)
Set UserNameInputBox = LoginForm.elements("username")
UserNameInputBox.Value = TextBox17.Text
Set SignInButton = LoginForm.elements(".save")
SignInButton.Click
'Wait for the new page to load
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
'Get the HTML document of the new page
Set doc = IE.document
End Sub