login issue

needhelp2

Active Member
Joined
Apr 19, 2011
Messages
250
Code:
Option Explicit

Private Sub Cancel_Click()
    Unload Me
End Sub

Private Sub Submit_Click()
    Excel.Application.Cursor = xlWait
    Launchyahooo Me.TextBox1.Value, Me.TextBox2.Value
    Unload Me
    Excel.Application.Cursor = xlDefault
End Sub

Private Sub Launchyahoo(username As String, password As String)
    Const strURL_c As String = "http://mail.yahoo.com"
    Dim objIE As SHDocVw.InternetExplorer
    Dim ieDoc As MSHTML.HTMLDocument
    Dim tbxPwdFld As MSHTML.HTMLInputElement
    Dim tbxUsrFld As MSHTML.HTMLInputElement
    Dim btnSubmit As MSHTML.HTMLInputElement
    On Error GoTo Err_Hnd
    'Create Internet Explorer Object
    Set objIE = New SHDocVw.WebBrowser
        'Navigate the URL
    objIE.Navigate strURL_c
    'Wait for page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    'Get document object
    Set ieDoc = objIE.Document
    'Get username/password fields and submit button.
    Set tbxPwdFld = ieDoc.all.Item("Passwd")
    Set tbxUsrFld = ieDoc.all.Item("Email")
    Set btnSubmit = ieDoc.all.Item("signIn")
    'Fill Fields
    tbxUsrFld.Value = username
    tbxPwdFld.Value = password
    'Click submit
    btnSubmit.Click
    'Wait for transistion page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    'Wait for main page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
Err_Hnd: '(Fail gracefully)
    objIE.Visible = True
End Sub
Any one tell me how this code works for mozila firefiox.I am using office 2003,2007
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
That code can't really be used with
 
Upvote 0
... FireFox, it automates Internet Explorer.
 
Upvote 0
Dear,on 02nd july it was working fine but since yesterday its again not working although i didnt change my script. please help me in this regards.
current code which i am using.its not auto filing fields now again :-(

Code:
Option Explicit
Private Sub Cancel_Click()
    Unload Me
End Sub
Private Sub Submit_Click()
    Excel.Application.Cursor = xlWait
    LaunchGamil Me.TextBox1.Value, Me.TextBox2.Value
    Unload Me
    Excel.Application.Cursor = xlDefault
End Sub
Private Sub LaunchGamil(username As String, password As String)
    Const strURL_c As String = "http://mail.yahoo.com"
    Dim objIE As SHDocVw.InternetExplorer
    Dim ieDoc As MSHTML.HTMLDocument
    Dim tbxPwdFld As MSHTML.HTMLInputElement
    Dim tbxUsrFld As MSHTML.HTMLInputElement
    Dim btnSubmit As MSHTML.HTMLInputElement
    On Error GoTo Err_Hnd
    'Create Internet Explorer Object
    Set objIE = New SHDocVw.InternetExplorer
    'Navigate the URL
    objIE.Navigate strURL_c
    'Wait for page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    'Get document object
    Set ieDoc = objIE.Document
    'Get username/password fields and submit button.
    Set tbxPwdFld = ieDoc.all.Item("Passwd")
    Set tbxUsrFld = ieDoc.all.Item("login")
    Set btnSubmit = ieDoc.all.Item(".save")
    'Fill Fields
    tbxUsrFld.Value = username
    tbxPwdFld.Value = password
    'Click submit
    btnSubmit.Click
    'Wait for transistion page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    'Wait for main page to load
    Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
Err_Hnd: '(Fail gracefully)
    objIE.Visible = True
End Sub
 
Upvote 0
I have simplified your code which hopefully will make it easier to understand.

The code for the Submit Button is unchanged.

Rather than using references to Microsoft Internet Controls and Microsoft HTML objects I have use late binding so we can directly set up objIE as an Internet Explorer Application.

Code:
    [color=darkblue]Dim[/color] objIE [color=darkblue]As[/color] [color=darkblue]Object[/color]
    
    [color=darkblue]On[/color] [color=darkblue]Error[/color] [color=darkblue]GoTo[/color] Err_Hnd
    
    [color=darkblue]Set[/color] objIE = CreateObject("InternetExplorer.Application")


Then all we need to do is load the webpage and insert values into the username and password fields.
Code:
    [color=darkblue]With[/color] objIE
      .Navigate strURL_c
      [color=darkblue]Do[/color] [color=darkblue]While[/color] .Busy: DoEvents: [color=darkblue]Loop[/color]
      [color=darkblue]Do[/color] [color=darkblue]While[/color] .ReadyState <> 4: DoEvents: [color=darkblue]Loop[/color]
      .Visible = [color=darkblue]True[/color]
      
      .Document.getElementById("Passwd").Value = password
      .Document.getElementById("login").Value = username
      .Document.getElementById(".save").Click
    [color=darkblue]End[/color] [color=darkblue]With[/color]

Putting it all together:

Code:
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] LaunchGamil(username [color=darkblue]As[/color] [color=darkblue]String[/color], password [color=darkblue]As[/color] [color=darkblue]String[/color])
    [color=darkblue]Const[/color] strURL_c [color=darkblue]As[/color] [color=darkblue]String[/color] = "http://mail.yahoo.com"
    
    [color=darkblue]Dim[/color] objIE [color=darkblue]As[/color] [color=darkblue]Object[/color]
    
    [color=darkblue]On[/color] [color=darkblue]Error[/color] [color=darkblue]GoTo[/color] Err_Hnd
    
    [color=darkblue]Set[/color] objIE = CreateObject("InternetExplorer.Application")
    
    [color=darkblue]With[/color] objIE
      .Navigate strURL_c
      [color=darkblue]Do[/color] [color=darkblue]While[/color] .Busy: DoEvents: [color=darkblue]Loop[/color]
      [color=darkblue]Do[/color] [color=darkblue]While[/color] .ReadyState <> 4: DoEvents: [color=darkblue]Loop[/color]
      .Visible = [color=darkblue]True[/color]
      
      .Document.getElementById("Passwd").Value = password
      .Document.getElementById("login").Value = username
      .Document.getElementById(".save").Click
    [color=darkblue]End[/color] [color=darkblue]With[/color]

Err_Hnd: [color=green]'(Fail gracefully)[/color]
    objIE.Visible = [color=darkblue]True[/color]
    [color=darkblue]Set[/color] objIE = [color=darkblue]Nothing[/color]
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
I don't know what other advice to give you I'm afraid. The code I posted works for me using Excel 2003.
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,568
Members
452,926
Latest member
rows and columns

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