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?
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?