Excel VBA for sending bulk sms to aPI
J'ai un programme excel vba fonctionnel, qui permet de facturer les service et de prendre le rendez-vous des clients. Je voudrais qu'un sms soit automatiquement envoyer au client chaque fois qu'on facture on enregistre un rendez-vous. Le sms en question pourrait être les remerciements, le montant de montant de la facture.
Un probleme similaire a déjà été traité dans un autre forum. Cependant il y a des elements ci-après que je n'ai pas compris dans ce code.
Mes connaissance en vba sont vraiment basiques. Pouvez vous m'aidez s'il vous plait.
Ci-dessous le code, ainsi que les lignes dont je ne comprends pas.
Merci d'avance
Sub send_SMS(xyz As Integer)
Application.ScreenUpdating = False
' Declaring varibles for sending sms
Dim HttpReq As New WinHttpRequest
Dim response As String
Dim sURL As String
Dim smsto, smstext As String
' Declaring varibles for Application
Dim lastrow, lastrow1, lastrow2, x, pointe As Long
lastrow = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
lastrow1 = Sheets(2).Range("A" & Rows.Count).End(xlUp).Row
lastrow2 = Sheets(3).Range("A" & Rows.Count).End(xlUp).Row
' Caculation of red card points
If xyz = 1 Then
pointe = (frmmain.txtpointe.Value - frmmain.txtpointr.Value) + (frmmain.txtamount.Value 10 / 100)
smstext = "Dear Member, You have reedemed " & frmmain.txtpointr.Text & " red points and your balance is " & pointe & " points"
Else
pointe = frmmain.txtpointe.Value + (frmmain.txtamount.Value * 10 / 100)
If pointe >= 1000 Then
smstext = "Dear Member, You have reached " & pointe & " red points and you can reedem it your next visit"
Else
smstext = "Dear Member, Your bill amount is " & frmmain.txtinvoice.Text & " and your Red Point balance is " & pointe & " Points"
End If
End If
' Checking for valid mobile number
If Len(frmmain.lblmobile.Caption) < 10 Then
Call nomobile(pointe)
Else
smsto = CStr(frmmain.lblmobile.Caption)
' //another way to create the HttpReq
Set HttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
' // API for sending sms
sURL = "" & smsto & "&text=" & smstext & "&route=Enterprise&type=text"
' Debug.Print sURL
On Error Resume Next
With HttpReq
.Open "GET", sURL, False
.send
End With
response = HttpReq.responseText
HttpReq.waitForResponse
' MsgBox Left(response, 2)
Debug.Print response
If Left(response, 2) = "OK" Then
Call nomobile(pointe)
Else
Call errorconnection(smstext, pointe)
End If
End If
sURL = ""
' Debug.Print sURL
On Error Resume Next
With HttpReq
.Open "GET", sURL, False
.send
End With
response = HttpReq.responseText
HttpReq.waitForResponse
frmmain.lblstatus.Caption = response
Debug.Print response
Application.ScreenUpdating = True
End Sub
The lines i dont understand
(xyz As Integer)
Dim lastrow, lastrow1, lastrow2, x, pointe As Long
lastrow = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
lastrow1 = Sheets(2).Range("A" & Rows.Count).End(xlUp).Row
lastrow2 = Sheets(3).Range("A" & Rows.Count).End(xlUp).Row
frmmain.txtpointe.Value + (frmmain.txtamount.ValuewBonjour Rodryg123,
A ma connaissance, pour pouvoir expédier un SMS depuis VBA, tu dois au préalable posséder un abonnement d'un service WEB offrant cette fonctionnalité.
(par exemple : https://www.smsmode.com/ mais je te conseille de googliser pour comparer les tarifs...)
Ensuite, on pourra voir le code VBA si nécessaire,
Merci GVIALLES.
Le problème a été résolu. Merci