A
alexm999
I am trying to add phone numbers into a websheet. With the code below, I
can only add 1 number at a time and the very 1st number on my list.
I'd like to add ALL the numbers in row A. Also, when it adds 1 number,
it adds funky numbers to the back, for example if the number was
12125551212 - it would look like 121255512121123400000
Any ideas? Heres the code: I blocked out my user name and password for
safety!
Private Declare Function GetIpAddrTable_API Lib "IpHlpApi" Alias
"GetIpAddrTable" (pIPAddrTable As Any, pdwSize As Long, ByVal bOrder As
Long) As Long
Private Function GetIpAddress()
Dim result As Long, Buf(511) As Byte, BufSize As Long
result = GetIpAddrTable_API(Buf(0), UBound(Buf) + 1, 1)
If result <> 0 Then
GetIpAddress = "127.0.0.1"
Else
For i = 0 To (Buf(1) * 256 + Buf(0) - 1)
IpAddress = ""
For j = 0 To 3
IpAddress = IpAddress & IIf(j > 0, ".", "") & Buf(4 + i
* 24 + j)
Next
If IpAddress <> "" Then
GetIpAddress = IpAddress
Exit Function
End If
Next i
End If
End Function
Private Function CreateFormData(ByRef Fields As Variant, ByVal
FormDataDelimiter As String, ParamArray Values() As Variant)
Dim FormData As String
FormData = FormDataDelimiter & vbCrLf
For i = 0 To UBound(Fields)
FormData = FormData & "Content-Disposition: form-data; name="""
& Fields(i) & """" & vbCrLf & vbCrLf & Values(i) & vbCrLf &
FormDataDelimiter & vbCrLf
Next i
CreateFormData = FormData
End Function
'
Public Sub UploadExcludeList()
Dim FormDataDelimiter As String
FormDataDelimiter = "---------------------------7d619d2ff0292"
Dim FormDataFile As String
FormDataFile = "C:\Documents and Settings\Alex
Markovich\Desktop\removeme1.csv"
Dim WebRoot As String
WebRoot = "https://www.protusfax.com/protus/"
Dim UserID As String
UserID = "888888"
Dim UserPassword As String
UserPassword = "password"
Dim UserIP As String
UserIP = GetIpAddress
'
############################################################################################################
Dim wHTTPReq As New WinHttpRequest
Dim StartTime As Date
wHTTPReq.Option(WinHttpRequestOption_UserAgentString) =
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322; .NET CLR 2.0.50727)"
wHTTPReq.Open "GET", WebRoot & "/general/FindAccounts.asp", False
wHTTPReq.Send
If wHTTPReq.Status <> 200 Then
Debug.Print "Session Could Not Be Created."
Exit Sub
End If
StartTime = Now()
wHTTPReq.Open "POST", WebRoot & "/general/FindAccounts.asp?",
False
wHTTPReq.SetRequestHeader "Referer", WebRoot &
"/general/FindAccounts.asp"
wHTTPReq.SetRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
wHTTPReq.SetRequestHeader "Cookie", "WT_FPC=id=" & UserIP & "-" &
"1619067696" & ":lv=" & (DateDiff("s", #1/1/1970#, StartTime) * 1000) &
":ss=" & (DateDiff("s", #1/1/1970#, Now()) * 1000)
wHTTPReq.Send "rt=&mpid=&bid=&cboFind=1&vfax=" & UserID & "&pw=" &
UserPassword & "&Submit=Login"
If wHTTPReq.Status <> 200 Then
Debug.Print "Login Unsuccessful."
Exit Sub
End If
wHTTPReq.Open "POST", WebRoot & "/contacts/listadmin.asp?u=1",
False
wHTTPReq.SetRequestHeader "Referer", WebRoot &
"/contacts/listadmin.asp"
wHTTPReq.SetRequestHeader "Content-Type", "multipart/form-data;
boundary=" & FormDataDelimiter
wHTTPReq.SetRequestHeader "Cookie", "WT_FPC=id=" & UserIP & "-" &
"1619067696" & ":lv=" & (DateDiff("s", #1/1/1970#, StartTime) * 1000) &
":ss=" & (DateDiff("s", #1/1/1970#, Now()) * 1000)
Dim FormData As String
FormData = CreateFormData(Split("smode:dim:uloadexclude", ":"),
"--" & FormDataDelimiter, 2, "", 7, 1)
FormData = FormData & "Content-Disposition: form-data;
name=""usearch""; filename=""" & FormDataFile & """" & vbCrLf
FormData = FormData & "Content-Type: application/vnd.ms-excel" &
vbCrLf & vbCrLf
Open FormDataFile For Input Access Read As #1
While Not EOF(1)
Line Input #1, WholeLine
FormData = FormData & WholeLine
Wend
Close #1
FormData = FormData & vbCrLf & "--" & FormDataDelimiter & "--" &
vbCrLf
wHTTPReq.Send FormData
If wHTTPReq.Status = 500 Then
Debug.Print "File Was Uploaded Successfully."
End If
End Sub
can only add 1 number at a time and the very 1st number on my list.
I'd like to add ALL the numbers in row A. Also, when it adds 1 number,
it adds funky numbers to the back, for example if the number was
12125551212 - it would look like 121255512121123400000
Any ideas? Heres the code: I blocked out my user name and password for
safety!
Private Declare Function GetIpAddrTable_API Lib "IpHlpApi" Alias
"GetIpAddrTable" (pIPAddrTable As Any, pdwSize As Long, ByVal bOrder As
Long) As Long
Private Function GetIpAddress()
Dim result As Long, Buf(511) As Byte, BufSize As Long
result = GetIpAddrTable_API(Buf(0), UBound(Buf) + 1, 1)
If result <> 0 Then
GetIpAddress = "127.0.0.1"
Else
For i = 0 To (Buf(1) * 256 + Buf(0) - 1)
IpAddress = ""
For j = 0 To 3
IpAddress = IpAddress & IIf(j > 0, ".", "") & Buf(4 + i
* 24 + j)
Next
If IpAddress <> "" Then
GetIpAddress = IpAddress
Exit Function
End If
Next i
End If
End Function
Private Function CreateFormData(ByRef Fields As Variant, ByVal
FormDataDelimiter As String, ParamArray Values() As Variant)
Dim FormData As String
FormData = FormDataDelimiter & vbCrLf
For i = 0 To UBound(Fields)
FormData = FormData & "Content-Disposition: form-data; name="""
& Fields(i) & """" & vbCrLf & vbCrLf & Values(i) & vbCrLf &
FormDataDelimiter & vbCrLf
Next i
CreateFormData = FormData
End Function
'
Public Sub UploadExcludeList()
Dim FormDataDelimiter As String
FormDataDelimiter = "---------------------------7d619d2ff0292"
Dim FormDataFile As String
FormDataFile = "C:\Documents and Settings\Alex
Markovich\Desktop\removeme1.csv"
Dim WebRoot As String
WebRoot = "https://www.protusfax.com/protus/"
Dim UserID As String
UserID = "888888"
Dim UserPassword As String
UserPassword = "password"
Dim UserIP As String
UserIP = GetIpAddress
'
############################################################################################################
Dim wHTTPReq As New WinHttpRequest
Dim StartTime As Date
wHTTPReq.Option(WinHttpRequestOption_UserAgentString) =
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322; .NET CLR 2.0.50727)"
wHTTPReq.Open "GET", WebRoot & "/general/FindAccounts.asp", False
wHTTPReq.Send
If wHTTPReq.Status <> 200 Then
Debug.Print "Session Could Not Be Created."
Exit Sub
End If
StartTime = Now()
wHTTPReq.Open "POST", WebRoot & "/general/FindAccounts.asp?",
False
wHTTPReq.SetRequestHeader "Referer", WebRoot &
"/general/FindAccounts.asp"
wHTTPReq.SetRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
wHTTPReq.SetRequestHeader "Cookie", "WT_FPC=id=" & UserIP & "-" &
"1619067696" & ":lv=" & (DateDiff("s", #1/1/1970#, StartTime) * 1000) &
":ss=" & (DateDiff("s", #1/1/1970#, Now()) * 1000)
wHTTPReq.Send "rt=&mpid=&bid=&cboFind=1&vfax=" & UserID & "&pw=" &
UserPassword & "&Submit=Login"
If wHTTPReq.Status <> 200 Then
Debug.Print "Login Unsuccessful."
Exit Sub
End If
wHTTPReq.Open "POST", WebRoot & "/contacts/listadmin.asp?u=1",
False
wHTTPReq.SetRequestHeader "Referer", WebRoot &
"/contacts/listadmin.asp"
wHTTPReq.SetRequestHeader "Content-Type", "multipart/form-data;
boundary=" & FormDataDelimiter
wHTTPReq.SetRequestHeader "Cookie", "WT_FPC=id=" & UserIP & "-" &
"1619067696" & ":lv=" & (DateDiff("s", #1/1/1970#, StartTime) * 1000) &
":ss=" & (DateDiff("s", #1/1/1970#, Now()) * 1000)
Dim FormData As String
FormData = CreateFormData(Split("smode:dim:uloadexclude", ":"),
"--" & FormDataDelimiter, 2, "", 7, 1)
FormData = FormData & "Content-Disposition: form-data;
name=""usearch""; filename=""" & FormDataFile & """" & vbCrLf
FormData = FormData & "Content-Type: application/vnd.ms-excel" &
vbCrLf & vbCrLf
Open FormDataFile For Input Access Read As #1
While Not EOF(1)
Line Input #1, WholeLine
FormData = FormData & WholeLine
Wend
Close #1
FormData = FormData & vbCrLf & "--" & FormDataDelimiter & "--" &
vbCrLf
wHTTPReq.Send FormData
If wHTTPReq.Status = 500 Then
Debug.Print "File Was Uploaded Successfully."
End If
End Sub