Inscription
  1. Comment ça marche ?
Methode HTTP : POST


Tout le monde connait Excel, le tableur de la suite bureautique Microsoft Office. Ce logiciel permet d'éffectuer vos calculs, d'analyser vos données afin de prendre de bonnes décisions. Dans ce document nous allons voir comment intégrer une solution d'envoi de SMS à vos applications Excel.
  1. Script VBA :
Sub SendSMS()
    Dim strReturn As String
    Dim Apikey As String
    Dim Number As String
    Dim Message As String
    Dim Expediteur As String

    Apikey = "VotreApiKey"
    Number = "33600000000"
    Message = "API VBA"
    Expediteur = "VBA"

    strReturn = send(Apikey, Number, Message, Expediteur, False)
End Sub
Function send(Apikey, Number, Message, Expediteur, MsgID) As String
    Dim objWinHTTP As Object
    Dim strReturn As String
    Dim Request As String
    Dim url As String

    Set objWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

    url = "http://www.envoyersms.biz/api/v1/?method=send"
    Request = "&apikey=" & URLEncode(Apikey) & "&number=" & URLEncode(Number)
    Request = Request & "&message=" & URLEncode(Message)
    Request = Request & "&expediteur=" & URLEncode(Expediteur) & "&msg_id=" & MsgID

    objWinHTTP.Open "GET", url & Request, False
    objWinHTTP.SetTimeouts 30000, 30000, 30000, 30000
    objWinHTTP.send
    If objWinHTTP.StatusText = "OK" Then
        strReturn = objWinHTTP.ResponseText
        Debug.Print strReturn
    End If

    Set objWinHTTP = Nothing
    send = strReturn
End Function
Public Function URLEncode(sRawURL) As String
    On Error GoTo Catch
    Dim iLoop As Integer
    Dim sRtn As String
    Dim sTmp As String
    Const sValidChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:/.?=_-$()~&"
    If Len(sRawURL) > 0 Then
        For iLoop = 1 To Len(sRawURL)
            sTmp = Mid(sRawURL, iLoop, 1)
            If InStr(1, sValidChars, sTmp, vbBinaryCompare) = 0 Then
                sTmp = Hex(Asc(sTmp))
                If sTmp = "20" Then
                    sTmp = "+"
                ElseIf Len(sTmp) = 1 Then
                    sTmp = "%0" & sTmp
                Else
                    sTmp = "%" & sTmp
                End If
            End If
            sRtn = sRtn & sTmp
        Next iLoop
        URLEncode = sRtn
    End If
    Finally:
        Exit Function
    Catch:
        URLEncode = ""
        Resume Finally
End Function
  1. Téléchargement :

Attention Attention les fichiers Excels contiennent des macros, pour que le script fonctionne correctement vous devez les activer. Si vous rencontrez des difficultées, consulter la FAQ. Une fois le fichier telecharger, vous allez devoir editer les macros, et saisir votre ApiKey.

Telecharger le script (Version Microsoft Excel 97-2003)
Telecharger le script (Version Microsoft Excel 2007)