Hi guys i am trying to follow this https://www.youtube.com/watch?v=Wn9L1MD_y0Y&t=107s on how to automate whatsapp with VBA.
This is the whole code.
Sub WebWhatsApp()
'Activate Selenium Type Library: Tools > Reference
Dim bot As New WebDriver
Dim ks As New Keys
'Init New Chrome instance & navigate to WebWhatsApp
bot.Start "chrome", "http://web.whatsapp.com/"
bot.Get "/"
'Ask user to scan the QR code. Once logged in, continue with macro
MsgBox "Please scan the QR code. After you are logged in, please confirm this message box by clicking"
'Determinate number of messages by identifying the number of last rows in column A
lastrow = Cells(Rows.Count, 1).End(x1Up).Row
'Search phonenumber/name, press enter, paste text into WebWhatsApp, press Enter to send message
For i = 2 To lastrow
'Get search text (phone number or name) from worksheet
searchtext = Sheets(1).Range("A" & i).Value
'Get textmessage from worksheet
textmessage = Sheets(1).Range("B" & i).Value
'click in the searchbox"
bot.FindElementByXPath("//*[@id="side"]/div[1]/div/label/div/div[2]").Click
'Wait 500 ms
bot.Wait (500)
'Insert search text(phone number or name)
bot.SendKeys (searchtext)
'Wait 500 ms
bot.Wait (500)
'Press Enter to confirm search text
bot.SendKeys (ks.Enter)
'Wait 500 ms
bot.Wait (500)
'Load message into WebWhatsApp
bot.SendKeys (textmessage)
'Wait 500 ms
bot.Wait (500)
'Press Enter to send the message
bot.SendKeys (ks.Enter)
Next i
'Get notification once done,
MsgBox "Done :)"
End Sub
Apparently i had an error from
bot.FindElementByXPath("//*[@id="side"]/div[1]/div/label/div/div[2]").Click
It states Compile error : Syntax error
Can Anyone tell me why? I have followed the instructions and codes clearly.