Topic Keywords: Excel, VBScript
A recent posting on the NowSMS Discussion Board has some interesting information on sending an SMS a link within an Excel spreadsheet.
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.
For comments and further discussion, please click here to visit the NowSMS Technical Forums (Discussion Board)...
4 Responses to “Sending SMS from Microsoft Excel”
Hi,
I am getting this error
Complie error:
Expected: list seperator or )
Try the version of the script at https://nowsms.com/discus/messages/1/41882.html
It looks like the formatting software here changes “quote” characters, so instead of “quote” … it displays “quote”. The alternative quote characters will not work in a macro.
I’ll try to edit this page to change this.
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.