VBA & Macro Problems

How to Send Bulk WhatsApp Messages with Attachments Using VBA

Nimra MalikNimra Malik Oct 26, 2026 868 views

Question details

The user wants to automate sending bulk WhatsApp messages with image or PDF attachments using VBA, while seamlessly skipping contacts that do not have active WhatsApp accounts.

How to Send Bulk WhatsApp Messages with Attachments Using VBA
Product
Spreadsheets
Device & OS
not provided
Scenario
Automating bulk messaging workflows via WhatsApp Web or the Desktop app directly from a spreadsheet.
Observed behavior
The macro stops running or becomes misconfigured when it encounters a mobile number that is not registered on WhatsApp.
Before you start

Ensure you have the WhatsApp Desktop application installed and logged in. Verify that your spreadsheet contains a clean list of contact numbers formatted with their respective international country codes.

Solution 1Recommended

Use VBA Error Handling to Skip Invalid WhatsApp Numbers

Implement an 'If' condition and 'GoTo' label within your VBA loop to bypass numbers that fail or are blank, ensuring the macro continues without stopping.

Because VBA cannot natively verify whether a phone number is registered on WhatsApp before attempting to send a message, the best approach is to manage the loop logic. By validating the cell data and handling potential UI timeouts or errors, you can force the macro to skip to the next row.

1
Define the loop structure

Set up a 'For' or 'Do While' loop in your VBA script to iterate through the spreadsheet rows containing the phone numbers and file attachment paths.

2
Add validation checks

Insert an 'If' statement at the beginning of the loop to check if the number cell is empty or invalid (e.g., If Cells(i, 1).Value = "" Then GoTo NextRecord).

3
Implement error handling

Use 'On Error Resume Next' or specific error trapping around the WhatsApp interaction code to prevent the macro from halting when WhatsApp fails to locate the contact.

4
Insert the NextRecord label

Place the label 'NextRecord:' directly before your 'Next i' or 'Loop' statement so the script knows where to jump when it needs to skip a contact.

Use VBA Error Handling to Skip Invalid WhatsApp Numbers
WhatsApp API Limitations: VBA relies on UI automation or deep links (like wa.me) to send messages. It cannot reliably check if a user exists on WhatsApp silently, so error handling and skipping are required workarounds.
Efficient VBA Support in WPS Spreadsheets

Automate Workflows with WPS Office Macros

WPS Office provides robust support for VBA and Macros, allowing you to run your WhatsApp automation scripts seamlessly while enjoying a highly compatible and lightweight spreadsheet environment.

  1. 1. Open your spreadsheet: Launch WPS Spreadsheets and open the file containing your contact list and VBA code.
  2. 2. Access Developer tools: Navigate to the 'Tools' tab on the top ribbon and select 'Developer' to access macro features.
  3. 3. Run the VBA script: Click 'Visual Basic Editor' to view, paste, or execute your bulk WhatsApp messaging script.
Fully compatible with Microsoft Excel VBA scripts and macro formats (.xlsm)Lightweight application that executes macros quickly and efficientlyFree to download and use for all standard office spreadsheet tasksBuilt-in support for managing complex datasets used for bulk messaging
microsoft office alternative - wps office

Frequently Asked Questions

Why does my VBA script stop when a number isn't on WhatsApp?

When the script attempts to interact with the WhatsApp application for an unregistered number, it encounters an unexpected UI state or popup indicating the number is invalid. Without proper error handling or 'GoTo' skip logic, this unexpected state causes the macro to crash or halt.

Can I send both images and PDFs using this VBA method?

Yes. By generating the appropriate file paths in your spreadsheet and passing them to your WhatsApp attachment sequence (usually via SendKeys, UI automation, or clipboard pasting), you can attach both images and PDFs within the same loop.

Do I need the WhatsApp Desktop app or WhatsApp Web for this to work?

Most VBA scripts for this purpose rely on opening a specific URL (like wa.me) via a shell command, which then triggers the WhatsApp Desktop app. Having the native desktop app installed and logged in usually provides a much more stable automation experience compared to browser-based WhatsApp Web.