ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem using internetexplorer object to open a url (https://www.excelbanter.com/excel-programming/411342-problem-using-internetexplorer-object-open-url.html)

Duncan[_7_]

Problem using internetexplorer object to open a url
 
I am trying to open a browser window from VBA and navigate to a
password-protected area but everything I have tried fails.

The navigate method fails with a url such as "http://
", I cannot get sendkeys to work either and using
formdata also seems to fail.

Can anyone provide a code snippett that opens page and hands over the
username and password?

Many thanks!

Leith Ross[_2_]

Problem using internetexplorer object to open a url
 
On May 21, 3:44 pm, Duncan wrote:
I am trying to open a browser window from VBA and navigate to a
password-protected area but everything I have tried fails.

The navigate method fails with a url such as "http://
", I cannot get sendkeys to work either and using
formdata also seems to fail.

Can anyone provide a code snippett that opens page and hands over the
username and password?

Many thanks!


Hello Duncan,

I wrote this macro to logon to Gmail from Internet Explorer. Add your
email and password to code where indicated.

'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Written: January 17, 2008
'Author: Leith Ross
'Summary: Logs on to Gmail using Internat Explorer
'This code first requires setting a reference to Microsoft Internet
Controls.
'In the Object Browser the properties, methods, and events appear
under SHDocVw.

Sub LogOnToGmail()

Dim IEapp As Object
Dim Password As String
Dim UserName As String
Dim URL As String

URL = "https://www.google.com/accounts/ServiceLogin?
service=mail&passive=true&rm=false&continue=https% 3A%2F
%2Fmail.google.com%2Fmail%3Fnsr%3D1%26ui%3Dhtml%26 zy
%3Dl&ltmpl=default&ltmplcache=2&hl=en/"
UserName = "Your UserName" <----- Change
Password = "Your Password" <-----Change

Set IEapp = New InternetExplorer

' Launch Internet Explorer and go to the site
With IEapp
.Visible = True
.Navigate URL
End With

' Wait until Internet Explore finishes loading
While IEapp.Busy
DoEvents
Wend

' Inserts your Email name
IEapp.Document.all("Email").Value = UserName
' Wait till the page is loaded
While IEapp.Busy
DoEvents
Wend

' Inserts your password
IEapp.Document.all("passwd").Value = Password
' Wait till the page is loaded
While IEapp.Busy
DoEvents
Wend

' Clicks the Sign In button
IEapp.Document.all("signIn").Click
While IEapp.Busy
DoEvents 'wait until IE is done loading page.
Wend

End Sub
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sincerely,
Leith Ross

Duncan[_7_]

Problem using internetexplorer object to open a url
 
Hi there!

This is great but it seems to work with a login where the username and
password fields are actually on a webpage. I need to log onto a
webpage using the password box that internet explorer pops up before
the page starts to load.

Very useful code though Leith, I can imagine I'll find a variety of
uses for it!

Best wishes,

Dunx


All times are GMT +1. The time now is 04:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com