I just started toying with VBA about a week ago. I can open IE and get to facebook. I can even enter my email in the right slot(because the cursor is already selected that spot). I cant seem to find a way to select the password field to enter my password. Let alone hit the log in 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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With