Automatically Send Message with Image via Whatsapp

How to automatically send message with image via Whatsapp using VBA.

Watch the video below:


Here’s the complete VBA code:
Option Explicit

Sub SendMessageWithPicViaWhatsapp()
Dim ie As InternetExplorer
Set ie = New InternetExplorer
Dim mytext As String
Dim myDir As String
mytext = Sheet1.Range(“C2”)

Dim myObj
Dim Pictur

Set myObj = ActiveSheet.DrawingObjects
For Each Pictur In myObj
If Left(Pictur.Name, 7) = “Picture” Then
Pictur.Select
Pictur.Delete
End If
Next

Dim EmployeeName As String, T As String

myDir = “C:\Users\takyar\Pictures\employees\”
EmployeeName = Range(“A2”) & Range(“B2”)
T = “.jpg”

On Error GoTo errormessage:

EmployeeName = Range(“A2”) & Range(“B2”)

ActiveSheet.Shapes.AddPicture Filename:=myDir & EmployeeName & T, linktofile:=msoFalse, _
savewithdocument:=msoTrue, Left:=240, Top:=15, Width:=60, Height:=60

errormessage:
If Err.Number = 1004 Then
MsgBox “File does not exist.” & vbCrLf & “Check the name of the employee!”
Range(“A2”).Value = “”
Range(“B2”).Value = “”
End If

ActiveSheet.Shapes(1).Copy

ie.navigate “https://web.whatsapp.com/send?phone=919810081867&text=” & mytext

Application.Wait (Now + TimeValue(“00:00:10”))

Call SendKeys(“^v”)
Call SendKeys(“{ENTER}”, True)
Application.Wait (Now + TimeValue(“00:00:05”))
Call SendKeys(“{ENTER}”, True)

End Sub

Refer to this video on how to add an appropriate image to a worksheet:

How to automatically send message with image via Whatsapp using VBA