HELP- Resubmission--VBA Code for Downloading a jpg from internet to local file is not working
Posted on 2012-03-29
I have VBA code that works well with xp and vista, but not with windows 7. I have a routine that downloads a jpeg file from the internet and stores to a local location, then inserts the jpeg into a database feild (part of a workorder profile).
This is an access 2002 runtime mde front end with a sqlserver express 2005 backend.
When capturing the jpeg, it works fine the first time. But when the jpeg is edited and refreshed via a remote location, Access will download the previous version; not the updated version. BUT when the access app is closed and reopened, it inserts the proper jpeg (about 14 kilobytes in size).
I don't know what is happening. I don't know why it behaves this way. I have used three variations of code and they all behave the same way. I will list 2 of them:
B = DownloadFile(UrlFileName:=URL, _
If B = True Then
Debug.Print "Download successful"
MsgBox "Download successful"
Debug.Print "Download unsuccessful: " & ErrorText
MsgBox "Download unsuccessful: Try Again" & ErrorText
Dim WinHttpReq As Object
Dim oStream As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False
myURL = WinHttpReq.ResponseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Type = 1
Set WinHttpReq = Nothing
Set oStream = Nothing
I was wondering if I was missing anything.
In the code, I also open 2 instance of internet explorer and refresh that site just in case.
(it is done twice- this resolved the same problem in vista and windows xp os)
Any help would be greatly appreciated. NEED HELP NOW...