Hi,
Jörg Ackermann:
There is no possibility to show pictures in a
form or in browser without downloading it to
local machine.
A short way should be to use MSXML:
---------Module basDownload--------------------
Option Compare Database
Option Explicit
Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" ( _
ByVal nBufferLength As Long, _
ByVal lpBuffer As String) _
As Long
Private Declare Function GetTempFileName Lib "kernel32" _
Alias "GetTempFileNameA" ( _
ByVal lpszPath As String, _
ByVal lpPrefixString As String, _
ByVal wUnique As Long, _
ByVal lpTempFileName As String) _
As Long
Private Const MAX_PATH = 255
Public Function DownloadPicture(ByVal strURL As String) As String
Dim xmlhttp As Object
Dim oStream As Object
Dim strTmp As String
On Error GoTo Err_DownloadPicture
Set xmlhttp = CreateObject("Msxml2.XMLHTTP")
With xmlhttp
.Open "GET", strURL, False
.setRequestHeader "CONTENT-TYPE", "image/jpeg"
.send
Do Until .readyState = 4
DoEvents
Loop
End With
strTmp = GetTmpFileName(Right(strURL, 3))
Set oStream = CreateObject("ADODB.Stream")
With oStream
.Mode = 3 'adModeReadWrite
'.Charset = "iso-8859-1"
.Type = 1 'adTypeBinary
.Open
.Write (xmlhttp.responseBody)
.SaveToFile strTmp
End With
Set oStream = Nothing
Set xmlhttp = Nothing
If Dir(strTmp) <> "" Then
If FileLen(strTmp) > 0 Then
DownloadPicture = strTmp
End If
End If
Exit_DownloadPicture:
Exit Function
Err_DownloadPicture:
MsgBox Err.Description
Resume Exit_DownloadPicture
End Function
Private Function GetTmpFileName(sSuffix As String) As String
Dim strPath As String, _
strFolder As String
Dim lngResult As Long
strFolder = String(MAX_PATH, 0)
lngResult = GetTempPath(MAX_PATH, strFolder)
strFolder = Left$(strFolder, InStr(1, strFolder, Chr$(0)) - 1)
strPath = String(MAX_PATH, 0)
lngResult = GetTempFileName(strFolder, "PIC", 0, strPath)
strPath = Left$(strPath, InStr(1, strPath, Chr$(0)) - 1)
GetTmpFileName = Replace(strPath, ".tmp", "." & sSuffix)
End Function
---------Module basDownload--------------------
In a form with a textbox(txtURL), a picturebox(picFoto) and a
comandbutton(cmdGo) you can do:
Private Sub cmdGo_Click()
Me!picFoto.Picture = DownloadPicture(Me!txtURL)
End Sub
Acki