Rabu, 03 April 2019

[MS_AccessPros] Does an URL Exist

 

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 (4)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar