dimanche 8 mars 2015

How to open another URL without losing first session in VBA?

So basically what my code does is logging out from Facebook, then logging in with the new email/password and then it has to open FB friendlist What happens though is when I open friendlist it is logged out again and I don't know why.


This is my code for excel macro



`Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer

Sub fbfriends()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyURL = "https://www.fb.com/"
MyBrowser.Navigate MyURL
MyBrowser.Visible = True
fbmail = Cells(1 + 0, 2 + 0)
fbpass = Cells(2 + 0, 2 + 0)
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
For Each MyHTML_Element In HTMLDoc.getElementsByClassName("uiLinkButtonInput")
MyHTML_Element.Click: Exit For
Next


Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
HTMLDoc.all.Email.Value = fbmail 'Enter your email id here
HTMLDoc.all.pass.Value = fbpass 'Enter your password here
For Each MyHTML_Element In HTMLDoc.getElementsByClassName("uiButton uiButtonConfirm")
MyHTML_Element.Click: Exit For
Next

MyBrowser.Navigate "fb.com/friends"

Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If

End Sub`




Aucun commentaire:

Enregistrer un commentaire