Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WinHttpReq.Open Verification

Status
Not open for further replies.

NanoCodez

IS-IT--Management
Feb 19, 2012
1
US
I am trying to read open (WinhttpReq) an xml file and save it to a directory in the root of c:\. The code is pretty straight forward but I think the code is either stepping through the code too quickly or the website is taking longer to honor the request

Dim WinHttpReq
Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
Dim sTemp

' Use the URL of the text file you wish to retrieve:
WinHttpReq.Open "GET", " False

WinHttpReq.Send
If (WinHttpReq.Status = 200) Then
sTemp = WinHttpReq.ResponseText
' Replace any carriage returns and linefeeds with spaces
sTemp = Replace(sTemp, vbCr, " ")
sTemp = Replace(sTemp, vbLf, " ")

WebText = sTemp
' msgbox(webtext)

'Create the 'weather' file
Set objFile = objFSO.OpenTextFile("C:\myWeather.txt", 8, True)
objFile.WriteLine sTemp
objFile.Close
Set objFile = Noth

Else
' Failed -- return empty string
WebText = ""
End If

When I run the code it does not return an error but the file does not appear in the folder.

Is there something that I'm missing that I should be adding to allow for the host to respond and send the file. Should I put up a prompt that would expose (or post) the xml file into a dialogue box to verify the code has actually read or parsed the file?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top