getting text into a macro

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
 
D

Doug Robbins - Word MVP

Try

Private Sub Document_Open()
Dim PhoneNumber As String
PhoneNumber = InputBox("Enter the Phone Number", "Phone Number")
Result = SendMessage("user", "password", PhoneNumber, "subject", "Hello
World")
End Sub


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top