Access Current IE with VBA

taraus88

New Member
Joined
Apr 8, 2006
Messages
18
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
 

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