Log into Facebook account and post

jaryszek

Board Regular
Joined
Jul 1, 2016
Messages
213
Hi Guys,

I was looking trough internet and forums but i have not found anything helpful so I am writing here.

I have code and this is working for me to log on Facebook:

Code:
Sub Login_facebook()     
    Dim ie As Object
     
     Dim aelement
     Dim btnInput
     Dim btnInputer
     
    Set ie = CreateObject("InternetExplorer.Application")
     
    ie.navigate "http://www.facebook.com/login.php"
     
    ie.Visible = True
     
    Do While ie.Busy And Not ie.readyState = 4
        DoEvents
    Loop
     
    DoEvents
     
    ie.document.All.Item("email").Value = "xxx@com.pl"
    ie.document.All.Item("pass").Value = "yyyyy"
    ie.document.All.Item("login").Click
     Application.Wait (Now + TimeValue("00:00:02"))
    ie.navigate "https://www.facebook.com/groups/496722467127307/"
    Do While ie.Busy And Not ie.readyState = 4
        DoEvents
    Loop

I would like to additionally post.
But i don't know how to find a specific class and find a button "send".

The class for writing text in posting windows is "_1mf _1mj" but
ie.document.all.getbyclassname("_1mf _1mj") doesn't work for me.

Przechwytywanie.jpg



Please help
Jacek Antek
 
Last edited:
Wow thank you !

Hmm from where do you know that

"u_0_n" is for login button and "xhpc_message" is for statusbox?

I am thinking how to search effectively for these different classes?

Jacek
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Open Firefox and right click anywhere on the page and click inspect element.

Now you'll find a mouse pointer on left of Inspector tab. Click the pointer and hover your mouse to desired item on page to find out respective properties of a item.
 
Upvote 0
Thank you Ombir.

I have clicked on "Co słychać" and only this class like in the attachment was showed.
Bez_tytu_u.jpg



So you had to know that this is for class xhpc_message :)

I know that is a HTML already but I am very curious :)
Maybe your way will teach me doing things like these in the future ?

Thank you once again!
Jacek Antek
 
Upvote 0
Hi MY Friends,


Could you please help with adding post for specific group ?


I have created group:


https://www.facebook.com/groups/1864378780474099/


and in my Inspector there is no xhpc-message class name, only "_1mf _1mj" like in attachment:

Bez_tytu_u.jpg


Unfortunately now code with xhpc-message it is not working.

Could you please tell me how in your inspector the class for posting in group is called?

Thank you in advance !

Warm regards,
Jacek Antek
 
Upvote 0
And one more question, is it possible to add images or videos via VBA while posting ?

Thank you Guys and thank you Ombir for your enormous help!

Jacek
 
Upvote 0
Try this for group posting:

Code:
Dim ie          As InternetExplorer
Sub Ombir_07Jan2017()
Dim doc         As HTMLDocument
Dim msg         As String
Dim Statusbox   As Object

Set ie = New InternetExplorer
msg = "Group Testing"

With ie
    .Visible = True
    .Navigate "https://www.facebook.com/groups/1864378780474099/"
    Call IEReady
End With

Set doc = ie.Document

doc.getElementById("email").Value = "jaryszek@o2.pl"
doc.getElementById("pass").Value = "Testtest1234"
doc.getElementById("loginbutton").Click
    Call IEReady
Do While Statusbox Is Nothing
    On Error Resume Next
    Set Statusbox = doc.getElementsByName("xhpc_message_text")(0)
Loop
On Error GoTo 0
    Statusbox.Value = msg
    Statusbox.Focus
    doc.getElementsByName("xhpc_message")(0).Value = msg
    Application.Wait Now() + TimeValue("00:00:02")
doc.getElementsByClassName("_1mf7 _4jy0 _4jy3 _4jy1 _51sy selected _42ft")(0).Click
    Application.Wait Now() + TimeValue("00:00:03")
    ie.Quit
End Sub
Sub IEReady()
Do While ie.Busy: DoEvents: Loop
waitfor 1
    Do While ie.ReadyState <> 4
        waitfor 3
    Loop
End Sub
Sub waitfor(ByVal nSec As Long)
nSec = nSec + Timer
    Do While Timer < nSec
       DoEvents
    Loop
End Sub

As far as I know, it is not possible to upload image/videos via VBA or it may be possible with help of complicated window APIs.

Another alternative might be possible with Autoit or Selenium. Google it.
 
Upvote 0
Wow you are the best Ombir !!!

Thank you very much, I will try to do this image uploading.

Best Wishes
Jacek Antek
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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