January 13, 2021

Upload Image PDF and Video files automatically via WhatsApp

How to upload image, pdf and video files automatically via Whatsapp desktop using VBA with Chrome, Selenium and Selenium Wrapper softwares.

Watch the video below:

Automate Different Files Uploads

Here’s the complete VBA code to automate uploading of different files via Whatsapp desktop:

Option Explicit
Dim driver As New WebDriver

Sub SendDataUsingChromeDriverSeleniumWrapper()

‘Chrome Driver
‘Selenium
‘Selenium Wrapper

Dim filepath As String, myMessage As String

Dim keys As New SeleniumWrapper.keys

myMessage = Sheet1.Range(“C2”)

filepath = InputBox(“Enter the file path”)

driver.Start “chrome”

driver.Get “https://web.whatsapp.com/send?phone=919810081867&text=” & myMessage

driver.Window.Maximize

driver.Wait 5000

driver.FindElementByXPath(“//div[@title=’Attach’]”).Click

driver.Wait 10000

driver.FindElementByXPath(“//input[@accept=’image/*,video/mp4,video/3gpp,video/quicktime’]”).SendKeys (filepath)

driver.Wait 2000 ‘ this wait time depends on the size of your file max 64 mb

driver.FindElementByXPath(“//span[@data-icon = ‘send’]”).Click

driver.Wait 2000

driver.SendKeys (keys.Enter)

End Sub

Automate Uploading of different Files via Whatsapp Desktop
Automate Uploading of different Files via Whatsapp Desktop

5 thoughts on “Upload Image PDF and Video files automatically via WhatsApp

  1. Uploading Files to WhatsApp with VBA.
    When I tried this code, I get the following Error
    “Runtime error ‘7 : NosuchElementError: Element Not Found for Xpath=//div[@title=”Attach”] when the code
    “driver.FindElementByXPath(“//div[@title=’Attach’]”).Click” is executed. I am not able to fix it.
    However, when I instruct “continue” with F5, the file gets attached and sent.
    Obviously, the WhatsApp has changed code since you have developed the system.
    Can you help me with a solution?
    Thanks.

    1. ‘BELOW TYPE WORK BUT NOT WORK ERROR SHOW

      ‘BELOW TYPE YOU CAN USE SIR AND TRY IT IT SHOWS ERROR
      ‘Sub SendDataUsingChromeDriver()
      ‘CHROMEdriver.SendKeys (keys.Enter)
      ‘PLEASE REPLY MY EMAIL ADDRESS NITIN.BHAVSAR.NITIN@GMAIL.COM
      ‘EXPECT FOR HELP AND REPLY

      Option Explicit

      Dim ChromeDriver

      Sub SendDataUsingChromeDriver()

      ‘ChromeDriver
      ‘Selenium
      ‘SeleniumWrapper

      Dim filepath As String, myMessage As String

      Dim ChromeDriver

      myMessage = Sheet1.Range(“C2”)

      filepath = InputBox(“Enter the file path”)

      ChromeDriver.Start “chrome”

      ChromeDriver.Get “https://web.whatsapp.com/send?phone=918200147197&TEXT=” & myMessage

      ChromeDriver.Window.Maximize

      ChromeDriver.Wait 5000

      ChromeDriver.FindElementByXPath(“//div[@title=’Attach’]”).Click

      ChromeDriver.Wait 10000

      ChromeDriver.FindElementByXPath(“//input[@accept=’image/*,video/mp4,video/3gpp,video/quicktime’]”).SendKeys (filepath)

      ChromeDriver.Wait 2000 ‘ this wait time depends on the size of your file max 64 mb

      ChromeDriver.FindElementByXPath(“//span[@data-icon = ‘send’]”).Click

      ChromeDriver.Wait 2000

      ChromeDriver.SendKeys (keys.Enter)

      End Sub

    2. Also I get same error, “Runtime error ‘7 : NosuchElementError: Element Not Found for Xpath=//div[@title=”Attach”] when the code
      “driver.FindElementByXPath(“//div[@title=’Attach’]”).Click” is executed. I am not able to fix it.

  2. Hello Sir I have a error on that can you please seggest me what i do there
    “Unknown error: cannot dind chrome binary”

    Please help sir

Comments are closed.