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

Published by

Dinesh Kumar Takyar

Welcome to exceltrainingvideos.com! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: http://youtube.com/familycomputerclub For a structured Excel VBA training course online you can visit: https://www.youtube.com/excelvbaonline

One thought on “Automatically Send Message with Image via Whatsapp”

  1. Hey Sir,

    What if I want to share the message with a group or a contact name instead of a Phone number?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.