Sending SMS from Microsoft Excel

Posted by on Oct 26, 2009 in Support Blog

Topic Keywords: ,

A recent posting on the NowSMS Discussion Board has some interesting information on sending an SMS a link within an Excel spreadsheet.

Read the full post here: https://nowsms.com/discus/messages/1/41882.html
The gist of the posting is that you cannot use the Excel HYPERLINK command to do this. It would be logical to build a NowSMS URL to send a message, but the HYPERLINK command connects to the URL twice, resulting in duplicate messages being sent.
As an alternative, Des created a VBScript macro instead. This macro initiates an HTTP connection to NowSMS to send a message, dynamically creating a message based upon cell values in the Excel spreadsheet. I’ve quoted the details from Des below:

The alternative approach is to write a simple VBScript macro instead.

Today was my first attempt at writing one … but I did manage to create a button in a spreadsheet, where when you click on the button, it reads data from the spreadsheet to send out an SMS.

Here’s what I did …

From the Developer menu in Excel, I added an Active X Command Button.

I then associated the following code with my command button:

Private Sub CommandButton1_Click()

Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")

URL = "http://192.168.0.222:8800/"

objHTTP.Open "POST", URL, False

objHTTP.send ("&PhoneNumber=" + Range("a9").Text + "&text=" + Range("a10").Text)

End Sub

In this particular case, I am extracting the phone number from cell A9, and the text to send from A10.

Once I exit design mode, I can click on the button, and it triggers this code, which makes the HTTP submission to NowSMS.

I’m using HTTP POST instead of GET to avoid some URL encoding issues.

It’s not as easy as using HYPERLINK, but hopefully you can adapt this to your scenario.



Post any questions or commands in the discussion board posting at https://nowsms.com/discus/messages/1/41882.html.

For comments and further discussion, please click here to visit the NowSMS Technical Forums (Discussion Board)...

4 Responses to “Sending SMS from Microsoft Excel”

  1. Hi,
    I am getting this error
    Complie error:

    Expected: list seperator or )

  2. How do i send the entire contents of the spreadsheet (assuming Row A has mobile numbers and Row B all the messages)?

    I tried a for loop to increment through the rows, but it only sends the contents of the first column, then gives me an error.

    for i = 1 to 5
    objHTTP.send (“&PhoneNumber=” + Range(“A” + i).Text + “&text=” + Range(“B” + i).Text)
    next

    • I believe you would need to repeat all of the actions within your loop.

      In other words, for each pass through the loop, you want to create an object, open, and send.