I've have created a UserForm with TextBoxs and CommandButtons. I use one TextBox to enter an account number such as: 123456789. I then click one of the CommandButtons to send Text from the TextBox to a current webpage HTMLInputBox. The code that I have created, instead creates a new webpage instead of choose the existing page I already have opened. This is the current code I'm using. Instead of using the current URL in the code, I'm replacing it with yahoo mail login page URL, "https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym". Yahoo has a User Id input box, a Password field, and Sign In button. Instead of using the Set IE = CreateObject("InternetExplorer.Application"), is there something else I could use to access or swithch to the page I already have up.
Private Sub CommandButton8_Click()
cURL "https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym"
Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputELement
Dim SignInButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Set IE = CreateObject("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)
'Get the User Name textbox and populate it
'<input name='login' id='username' maxlength='96' tabindex='1' value=''>'
Set UserNameInputBox = LoginForm.elements("username")
UserNameInputBox.Value = TextBox17.Text
'Get the form input button and click it
'<button type='submit' id='.save' name='.save' class='secondaryCta' tabindex='5'>
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
Private Sub CommandButton8_Click()
cURL "https://login.yahoo.com/config/login_verify2?.intl=us&.src=ym"
Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UserNameInputBox As HTMLInputELement
Dim SignInButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Set IE = CreateObject("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)
'Get the User Name textbox and populate it
'<input name='login' id='username' maxlength='96' tabindex='1' value=''>'
Set UserNameInputBox = LoginForm.elements("username")
UserNameInputBox.Value = TextBox17.Text
'Get the form input button and click it
'<button type='submit' id='.save' name='.save' class='secondaryCta' tabindex='5'>
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