SMS tutorials >
Sending SMS from Excel
This tutorial illustrates how to send and receive SMS from a Microsoft Excel worksheet using the SMSLibX ActiveX component (DLL library).
The tutorial shows how to:
- build step-by-step a new Excel worksheet sending/receiving SMS;
- integrate SMS sending/receiving into an existing Excel worksheet ;
- download some ready-to-use Excel SMS examples and adapt them to your needs.
The reference environment is Microsoft Excel 2000 .
A minimal expertise on VBA programming (Visual Basic for Applications ) is required.
- Download and install SMSLibX on your PC.
- (Optional) Download and install our Excel SMS examples (sending/receiving SMS from VBA source code).
- Connect and install your GSM modem or phone to your PC.
Integrating SMSLibX into Excel
- Open an existent Excel worksheet or create a new one.
- Switch to the VBA source code (Tools > Macro > Visual Basic Editor), then select your worksheet in the Project tree.
- Set up a reference to SMSLibX library (Tools > References menu).
Sending and receiving SMS from Excel (VBA)
The following VBA source code might be used into an Excel worksheet module, in order to send and receive SMS messages. With few modifications this code can be inserted in a VBA class module too.
The WithEvents clause is essential in order to catch events raised by the SMSModem object.
Using SMSLibX in your VBA editor
For a brief introduction on SMSLibX usage we recommend the Quick start section from SMSLibX Help.
SMSLibX is fully integrated into the Microsoft VBA development environment:
Two examples: Excel worksheets sending/receiving SMS
The following Excel worksheets provided with VBA source code are available for download :
Minimal example sending and receiving SMS.
Medium-complexity example sending and receiving multiple SMS.
Both examples are pre-configured for simulation mode (they do not send real SMS).
Once you got them working on yoir PC, you can configure them in order to use your actual GSM modem/phone by opening the worksheet source code (Tools > Macro > Visual Basic Editor menu) and modifying the 'TO DO' items.
SMSLibX events and VB6 programming
Please read these notes carefully – they are very important for a good SMSLibX programming practice!
MsgBox and received SMS messages
If your VBA application makes use of MsgBox and InputBox. please note that VBA suppresses events from timers, forms, controls and ActiveX components while one of these dialogs is open.
Events are not simply delayed but definitively suppressed (please see Microsoft Knowledge Base 76557 article).
Due to this disagreeable behaviour, if a MsgBox is open your application may loose events notifying received messages - and any other event generated by SMSLibX.
As work-around. we suggest redefining the VBA MsgBox function and replacing it with the MessageBox API from Windows (which does not suppress events: please see Microsoft Knowledge Base 76557 article for details).
A concrete MsgBox re-definition example is available in the example source code
distributed with this tutorial.
Yielding control in your loops
If your VBA application cycles over a list of SMS messages to be sent - or performs some other time-consuming operations - then you should provide a DoEvents statement in your loop (or time-consuming operaton).
This will permit SMSLibX to continue raising its events in real-time (such as received messages, delivery reports and modem status events).
Moreover, your SMSLibX event listeners (the code you write inside an event procedure) should never contain time-consuming operations, since SMSLibX relies on the event calling thread for further message capture and notification.
SMSLibX registration problems
When opening the examples you might experience some troubles due to missing SMSLibX registration on your system.Source: www.smsco.it