Hi, I'm reading a web site from VBA but I'm having trouble closing the connection aftwerwards.
hOpen = InternetOpen("", _
INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, _
vbNullString, _
vbNullString, _
0&)
hFile = InternetOpenUrl(hOpen, sURL, "", 0, INTERNET_FLAG_RELOAD, ByVal 0&)
sBuffer = ""
Do
readOk = InternetReadFile(hFile, smallBuff, Length, Ret)
If readOk Then sBuffer = sBuffer + Left(smallBuff, Ret)
Loop While readOk And Ret > 0
If (InternetCloseHandle(hFile)) = False Then
MsgBox "File close failed"
End If
If Err.LastDllError <> 0 Then
MsgBox "File close failed-" & Err.LastDllError
End If
Trying to call InternetCloseHandle for hFile always returns true but Err.LastDllError is always set to 6.
What am I doing wrong ?
I then close hOpen successfully, but any further attempt to run this section of code freezer, presumably beacuse the close of hFile didn't work correctly.
Thanks
hOpen = InternetOpen("", _
INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, _
vbNullString, _
vbNullString, _
0&)
hFile = InternetOpenUrl(hOpen, sURL, "", 0, INTERNET_FLAG_RELOAD, ByVal 0&)
sBuffer = ""
Do
readOk = InternetReadFile(hFile, smallBuff, Length, Ret)
If readOk Then sBuffer = sBuffer + Left(smallBuff, Ret)
Loop While readOk And Ret > 0
If (InternetCloseHandle(hFile)) = False Then
MsgBox "File close failed"
End If
If Err.LastDllError <> 0 Then
MsgBox "File close failed-" & Err.LastDllError
End If
Trying to call InternetCloseHandle for hFile always returns true but Err.LastDllError is always set to 6.
What am I doing wrong ?
I then close hOpen successfully, but any further attempt to run this section of code freezer, presumably beacuse the close of hFile didn't work correctly.
Thanks