Using VBA to post a status update to Facebook

mwperkins

Board Regular
Joined
Oct 29, 2002
Messages
156
Hi,
I've found solutions elsewhere that can log into Facebook using Excel VBA, but cannot get it to work:

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

'~~> Change as Applicable
sUser = "someone@somewhere.com"
sPass = "password1234"

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"))

' The following line gives an error if I am already logged into facebook in another window. How can I test for this and workaround?
ie.document.All.Item("email").Value = sUser
ie.document.All.Item("pass").Value = sPass
ie.document.All.Item("loginbutton").Click
Do While ie.Busy: DoEvents: Loop

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

' The following line creates error 91. What am I doing wrong?
ie.document.All.Item("status").Select
ie.document.All.Item("u_0_10").Value = "Hello World"

' What code do I need to click the "Post" button?
' What code do I need to confirm that the posting was successful?
' What code do i need to log out of facebook and close the IE window?
End Sub


any help appreciated
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
does that place allow you to log in and post automatically in their rules
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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