Dear friends
By googling the error code I eventually solved the problem:
The string imageURL has to include http:// - and it works!
We have a saying, which translated from Danis is something like: "A blind hen can also find a grain"
Best regards
Peter
Dear friends
In my DB with 30,000 stereoscopic images there is normally an image for each record. If not, an alternative image will be shown.
In the online version the check is:
If Dir(Image) = "" Then 'check if image exists
but obviously it is not that easy off line.
From the internet I have found some code, but I cannot make it work:
In a module I have following function:
Option Compare Database
Option Explicit
Public HttpRequest As Object
_______________________________________________________________________
Public Function URLExists(imageURL As String) As Boolean
Dim Request As Object
Dim ff As Integer
Dim rc As Variant
'On Error GoTo Endnow
Set Request = CreateObject("WinHttp.WinHttpRequest.5.1")
With Request
.Open "GET", imageURL, False 'OBJECT REQUIRED
.Send
rc = .StatusText
End With
Set Request = Nothing
If rc = "OK" Then URLExists = True
Exit Function
Endnow:
End Function
For the form, which opens the URL (the image), the code is:
Private Sub Form_Current()
Dim imageURL As String
Dim Filename As String
Filename = [LBNR] & ".jpg"
imageURL = "www.fotohistoricum.dk/rods/samling/" & Left([LBNR], 2) & "/" & Filename
URLExists (imageURL)
MsgBox imageURL, vbInformation, URLExists(imageURL) 'gives the correct URL and "False"
'some code missing here
With Me.Webbrowser20
.ControlSource = "=" & """" & imageURL & """"
End With
End Sub
The function URLExists always return "false", also if the image exists.
The problem is in the line in bold with the error message "Object required".
Any suggestion on what I am doing wrong?
Best regards
Peter
Posted by: Peter =?iso-8859-1?q?Randl=F8v?= <randlov@post9.tele.dk>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
Tidak ada komentar:
Posting Komentar