PDA

View Full Version : Login to yahoo mail.



needhelp1
06-29-2011, 12:48 AM
i am using file to login to yahoo from IE,but as its working slow i need same script for mozila firefox.can any one assit me?

needhelp1
06-29-2011, 09:40 PM
is there any one who could help me this regard?

mancubus
06-29-2011, 10:48 PM
hi.

see one of our members post in MrExcel.

http://www.mrexcel.com/forum/showpost.php?p=2641771&postcount=5

needhelp1
06-29-2011, 10:50 PM
where i have to replace this code related to shell, infect i am no0t too good with vba.

needhelp1
06-30-2011, 12:20 AM
where i have to replace this code related to shell, infect i am no0t too good with vba.

is there any way that if IE is disabled the it call firefox to run for process?

Kenneth Hobs
06-30-2011, 05:08 AM
Your code uses the object model from MSIE. I don't know that Firefox even has an object model. As such, the only way to do it in Firefox that I know of is by Sendkeys. MSIE method is the best in this case.

needhelp1
06-30-2011, 05:14 AM
K right but is it code works for yahoo as well? if yes then how?

Kenneth Hobs
06-30-2011, 05:46 AM
I don't understand what you just asked. MSIE object model code works for MSIE. It is like the object model code for Excel does not work for the spreadsheet in OpenOffice. The syntax is similar but different.

If you are tied to using Firefox then you should explore the options that Firefox might offer. Go to a search engine and look for "Firefox Object Model Code". Looking for "Firefox VBA" you will find a link to: http://www.iol.ie/~locka/mozilla/control.htm

I think that the control in the link above might help you. I will not have time to explore it until this weekend.

needhelp1
06-30-2011, 11:01 PM
I was asking that how it works if i auto copy id and password to login windoe from sheet named (user data) from range a:a,b:b id and password respectively? i am searching such thing since a week.

Kenneth Hobs
07-01-2011, 06:41 AM
What I wonder is, why do you even need a userform? I could show you how to insert range values and fix other issues but the method below seems better to me.

Set the references in VBE's Tools as you have in your posted workbook or simply add this code to that workbook. Put this code in a Module. The Test routine passes a Sheet named "Main" with cell "A1" containing the yahoo id with or without the "@yahoo.com" and cell "A2" containing the password. Then, simply play the Test sub.

The routine does error gracefully after closing IE. I don't have time to check that but maybe someone can jump in here and tell us how to avoid that without the error goto. I don't like using error goto's if I can avoid them.

Sub Test_LoginYahoo()
LoginYahoo ThisWorkbook.Worksheets("Main").Range("A1").Value2, _
ThisWorkbook.Worksheets("Main").Range("A2").Value2
End Sub

Sub LoginYahoo(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

Excel.Application.Cursor = xlWait
If InStr(username, "@") = 0 Then username = username & "@yahoo.com"

On Error GoTo Err_Hnd

'Create Internet Explorer Object
Set objIE = New SHDocVw.InternetExplorer
'Navigate the URL
objIE.Navigate strURL_c
objIE.Visible = False
'Wait for page to load
Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
'Do While objIE.Busy Or objIE.ReadyState <> READYSTATE_COMPLETE
' DoEvents
'Loop
'Set document object
Set ieDoc = objIE.Document
ieDoc.getElementsByName("passwd").Item(0).Value = password
ieDoc.getElementsByName("username").Item(0).Value = username
ieDoc.forms("Login_form").Submit

Err_Hnd: '(Fail gracefully)
objIE.Visible = True
On Error GoTo 0
Excel.Application.Cursor = xlDefault
End Sub