C
Col Shaw
Hi,
The following macro works fine, but instead of putting a phone number in the
function call i would like to use a phone number i generate from our
database, this number could be input into the 1st line of the word document
automatically,but i dont see how i can then get it into the macro. If any
one can point me in the right direction i would be very grateful, or even
list some popular Word/vb forums.
*************************
Private Sub Document_Open()
Result = SendMessage("user", "password", "*INPUT NUMBER HERE*phone number",
"subject", "Hello World")
End Sub
Function SendMessage(strUserName, strPassword, strSmsTo, strSMSFrom,
strSmsMsg)
Dim xmlhttp, sResponse
strUserName = URLEncode(strUserName)
strPassword = URLEncode(strPassword)
strSmsTo = URLEncode(strSmsTo)
strSMSFrom = URLEncode(strSMSFrom)
strSmsMsg = URLEncode(strSmsMsg)
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", "http://www.24x.com/sendsms/sendsms.aspx", False
xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xmlhttp.send "user=" & strUserName & "&password=" & strPassword &
"&smsto=" & strSmsTo & "&smsfrom=" & strSMSFrom & "&smsmsg=" & strSmsMsg
sResponse = xmlhttp.responseText
Set xmlhttp = Nothing
SendMessage = sResponse
End Function
Function URLEncode(strData)
Dim I, strTemp, strChar, strOut, intAsc
strTemp = Trim(strData)
For I = 1 To Len(strTemp)
strChar = Mid(strTemp, I, 1)
intAsc = Asc(strChar)
If (intAsc >= 48 And intAsc <= 57) Or _
(intAsc >= 97 And intAsc <= 122) Or _
(intAsc >= 65 And intAsc <= 90) Then
strOut = strOut & strChar
Else
strOut = strOut & "%" & Hex(intAsc)
End If
Next
URLEncode = strOut
End Function
The following macro works fine, but instead of putting a phone number in the
function call i would like to use a phone number i generate from our
database, this number could be input into the 1st line of the word document
automatically,but i dont see how i can then get it into the macro. If any
one can point me in the right direction i would be very grateful, or even
list some popular Word/vb forums.
*************************
Private Sub Document_Open()
Result = SendMessage("user", "password", "*INPUT NUMBER HERE*phone number",
"subject", "Hello World")
End Sub
Function SendMessage(strUserName, strPassword, strSmsTo, strSMSFrom,
strSmsMsg)
Dim xmlhttp, sResponse
strUserName = URLEncode(strUserName)
strPassword = URLEncode(strPassword)
strSmsTo = URLEncode(strSmsTo)
strSMSFrom = URLEncode(strSMSFrom)
strSmsMsg = URLEncode(strSmsMsg)
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", "http://www.24x.com/sendsms/sendsms.aspx", False
xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xmlhttp.send "user=" & strUserName & "&password=" & strPassword &
"&smsto=" & strSmsTo & "&smsfrom=" & strSMSFrom & "&smsmsg=" & strSmsMsg
sResponse = xmlhttp.responseText
Set xmlhttp = Nothing
SendMessage = sResponse
End Function
Function URLEncode(strData)
Dim I, strTemp, strChar, strOut, intAsc
strTemp = Trim(strData)
For I = 1 To Len(strTemp)
strChar = Mid(strTemp, I, 1)
intAsc = Asc(strChar)
If (intAsc >= 48 And intAsc <= 57) Or _
(intAsc >= 97 And intAsc <= 122) Or _
(intAsc >= 65 And intAsc <= 90) Then
strOut = strOut & strChar
Else
strOut = strOut & "%" & Hex(intAsc)
End If
Next
URLEncode = strOut
End Function