VBA code to login

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
something to get you started:

https://msdn.microsoft.com/en-us/library/ms970456.aspx



Code:
Sub navy()
Dim objIE As Object
Dim objHTML As Object


Set objIE = CreateObject("internetExplorer.Application")


objIE.Visible = True
objIE.navigate URL:="https://yardi.starlightinvest.com/voyager6008sp17/pages/Login.aspx"


While objIE.readyState <> 4
    DoEvents
Wend


Set objHTML = objIE.document


objHTML.getElementById("Username").innerText = "myUserName"
objHTML.getElementById("Password").innerText = "MyPassword"
objHTML.getElementById("button1").Click


Set objIE = Nothing
Set objHTML = Nothing
End Sub
 
Upvote 0
Hi VBA Greek,

Thanks for the help, but unfortunatley it is giving me an error saying.

"Run- time error '-2147417848 (80010108)':

Automation errror
The object invoked has disconnected from its clients"

When I click debug, It highlights the vba code below.

While objIE.readyState <> 4

Can you please guide me with this ?
 
Upvote 0
Thanks that works. But now giving error for the below vba line saying;

"Method 'Document' of object 'IWebBrowser 2' failed"

Set objHTML = objIE.document
 
Upvote 0
Thanks that works. But now giving error for the below vba line saying;

"Method 'Document' of object 'IWebBrowser 2' failed"

Set objHTML = objIE.document

that is I think because the browser is not done loading the website yet, that is why I think the first option is better
 
Upvote 0

Forum statistics

Threads
1,216,040
Messages
6,128,454
Members
449,455
Latest member
jesski

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