Trying to login to facebook using VBA

I just started doing VBA about a week ago. I can open IE and go to facebook. I can even enter my email address in the correct slot (because the cursor has already selected that location). I cannot find a way to select the password field to enter my password. Not to mention pressing the login button. Please, help

here is my code so far

Sub facebookPost()

    Dim IE As Object

    Set IE = CreateObject("INTERNETEXPLORER.Application")
    IE.Navigate ("www.Facebook.com")
    IE.Visible = True

    Do While IE.Busy
      DoEvents
    Loop

    Application.Wait (Now + TimeValue("00:00:02"))

    IE.Document.all.Item("email").Value = "*******"
    IE.Document.all.Item("pass").Value = "********"
End Sub

      

+3


source to share


2 answers


This is the source of the button

<label class="uiButton uiButtonConfirm" id="loginbutton" for="u_0_4"><input value="Log in" tabindex="4" id="u_0_4" type="submit"></label>

This works for me



IE.Document.all.Item("loginbutton").Click

      

So your code looks like this

Sub facebookPost()
    Dim IE As Object
    Dim sUser As String, sPass As String

    '~~> Change as Applicable
    sUser = "Blah Blah"
    sPass = "Blah Blah"

    Set IE = CreateObject("INTERNETEXPLORER.Application")

    IE.Navigate ("www.Facebook.com")
    IE.Visible = True

    Do While IE.Busy: DoEvents: Loop

    Application.Wait (Now + TimeValue("00:00:02"))

    IE.Document.all.Item("email").Value = sUser
    IE.Document.all.Item("pass").Value = sPass
    IE.Document.all.Item("loginbutton").Click
End Sub

      

+5


source


Instead of loginbutton, just write login and it works for me



0


source







All Articles